From 32ddd94f629bdca2a20fac34021722ae9c15d96f Mon Sep 17 00:00:00 2001 From: Luis Garcia Date: Wed, 24 May 2017 18:10:13 -0400 Subject: [PATCH 1/3] finished lab 1 --- index.html | 20 ++++----- js/script.js | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 122 insertions(+), 12 deletions(-) diff --git a/index.html b/index.html index b16c318..55d9418 100644 --- a/index.html +++ b/index.html @@ -20,16 +20,16 @@

Loops Exercises

diff --git a/js/script.js b/js/script.js index ba8cf69..5f62927 100644 --- a/js/script.js +++ b/js/script.js @@ -2,6 +2,116 @@ var display = document.getElementById("display"); -function yourFunctionName (){ - display.innerHTML = "hello"; +function oneToTen() +{ + display.innerHTML= "***Output**
"; + for(i =1; i < 11; i++) + { + display.innerHTML+= i; + display.innerHTML += "
"; + } +} + +function oddNumbers() +{ + display.innerHTML= "***Output**
"; + for(i =1; i < 20; i++) + { + display.innerHTML+= i; + display.innerHTML += "
"; + i++; + } +} + +function squares() +{ + display.innerHTML= "***Output**
"; + for(i =1; i < 11; i++) + { + display.innerHTML+= i*i; + display.innerHTML += "
"; + } +} + +function random4() +{ + display.innerHTML= "***Output**
"; + for(i =1; i < 5; i++) + { + display.innerHTML+= Math.floor((Math.random() * 100) + 1);; + display.innerHTML += "
"; + } +} + +function even(num) +{ + display.innerHTML= "***Output**
"; + for(i =2; i < num; i++) + { + display.innerHTML+=i; + display.innerHTML += "
"; + i++; + } +} + +function powers(num) +{ + display.innerHTML= "***Output**
"; + for(i =1; i <= num; i++) + { + display.innerHTML+=Math.pow(2,i); + display.innerHTML += "
"; + } +} + +function areWeThereYet() +{ + var there = "quit"; + display.innerHTML= "***Output**
"; + while(there != "yes") + { + there = prompt("areWeThereYet?") + display.innerHTML= "areWeThereYet?
"; + } + display.innerHTML= "Good
"; + +} + +function triangle() +{ + display.innerHTML= "***Output**
"; + for(i = 1; i < 7; i++) + { + for(j = 1; j < i; j++) + { + display.innerHTML+="*"; + } + display.innerHTML+="
"; + } +} + +function tableSquare() +{ + display.innerHTML= "***Output**
A4x4tablesquare
"; + for(i = 1; i < 5; i++) + { + for(j = 1; j < 5; j++) + { + display.innerHTML+=" | " +i*j; + } + display.innerHTML+=" |
"; + } +} + +function tableSquare(num) +{ + display.innerHTML= "***Output**
A"+num+"x"+num+"tablesquare
"; + for(i = 1; i < num+1; i++) + { + for(j = 1; j < num+1; j++) + { + display.innerHTML+=" | " +i*j; + } + display.innerHTML+=" |
"; + } } From ace29e80f845979282b12a764ab21023dc3915e3 Mon Sep 17 00:00:00 2001 From: Luis Garcia Date: Wed, 24 May 2017 19:30:00 -0400 Subject: [PATCH 2/3] fixed name collision --- index.html | 2 +- js/script.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 55d9418..45353df 100644 --- a/index.html +++ b/index.html @@ -29,7 +29,7 @@

Loops Exercises

  • -
  • +
  • diff --git a/js/script.js b/js/script.js index 5f62927..4db992b 100644 --- a/js/script.js +++ b/js/script.js @@ -103,7 +103,7 @@ function tableSquare() } } -function tableSquare(num) +function tableSquares(num) { display.innerHTML= "***Output**
    A"+num+"x"+num+"tablesquare
    "; for(i = 1; i < num+1; i++) From 2fdbcf2616d51982cbd24e95c827691308781e63 Mon Sep 17 00:00:00 2001 From: Luis Garcia Date: Thu, 25 May 2017 08:12:20 -0400 Subject: [PATCH 3/3] updated buttons --- index.html | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index 45353df..8363602 100644 --- a/index.html +++ b/index.html @@ -20,16 +20,16 @@

    Loops Exercises