diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..61a9130 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..c94d2df --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,37 @@ + + + + false + + false + false + + + + + + + + + + + + 1.8 + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..d90ca6f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..73bf467 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,618 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + project + + + true + + + + DIRECTORY + + false + + + + + + + + + + + + + + + 1484947970301 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Java2JavaScript-Lab-1.iml b/Java2JavaScript-Lab-1.iml new file mode 100644 index 0000000..80cc739 --- /dev/null +++ b/Java2JavaScript-Lab-1.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/index.html b/index.html index b16c318..9748679 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..5598e1f 100644 --- a/js/script.js +++ b/js/script.js @@ -5,3 +5,92 @@ var display = document.getElementById("display"); function yourFunctionName (){ display.innerHTML = "hello"; } + +function oneToTen() { + display.innerHTML += "oneToTen()
*** Output ***
"; + //var answer = prompt("Whats your number?"); + for(var i=1; i<=10; i++) + display.innerHTML += i + "
"; +} + +function oddNumbers() { + display.innerHTML += "oddNumbers()
*** Output ***
"; + var dummy =0; + //var answer = prompt("Whats your number?"); + for(var i=1; i<=20; i++) + (i%2)==0? display.innerHTML += "" : display.innerHTML += i + "
"; +} + +function squares() { + display.innerHTML += "squares()
*** Output ***
"; + //var answer = prompt("Whats your number?"); + for(var i=1; i<=10; i++) + display.innerHTML += i*i + "
"; +} + +function random4() { + display.innerHTML += "random4()
*** Output ***
"; + //var answer = prompt("Whats your number?"); + for(var i=1; i<=4; i++) + display.innerHTML += Math.ceil(Math.random()*100)+1 + "
"; +} + +function even() { + var n = prompt("Whats your number?"); + display.innerHTML += "even(" + n +")
*** Output ***
"; + for(var i=1; i" : display.innerHTML += "" ; +} + +function powers() { + var n = prompt("Whats your number?"); + display.innerHTML += "powers(" + n +")
*** Output ***
"; + for(var i=1; i<=n; i++) + display.innerHTML += Math.pow(2,i) + "
"; +} + +function areWeThereYet() { + var userInput = prompt("Are we there yet?"); + while(userInput!="Yes"){ + display.innerHTML += "Arewethereyet?
" + userInput + "
"; + userInput = prompt("Are we there yet?"); + } + display.innerHTML += userInput + "
Good!"; +} + +function triangle(){ + display.innerHTML += " triangle()
*** Output ***
"; + var stars; + for(var i=0; i<6; i++) { + for (var j = 0; j < i; j++) { + stars += "*"; + } + display.innerHTML += " " + stars + "
"; + stars = " "; + } +} + +function tableSquare(){ + display.innerHTML += " tableSquare()
*** Output ***
"; + var testStr = "| "; + for(var i=1; i<=4; i++){ + for(var j=1; j<=4; j++){ + testStr += i*j>=10? " " + i*j + " |" : " " + i*j + " |" ; + } + display.innerHTML += testStr + "
"; + testStr = "| "; + } +} + +function tableSquares(){ + var userNum = prompt("Whats your number?"); + display.innerHTML += " tableSquare(" + userNum + ")
*** Output ***
"; + var testStr = "| "; + for(var i=1; i<=userNum; i++){ + for(var j=1; j<=userNum; j++){ + testStr += i*j>=10? " " + i*j + " |" : " " + i*j + " |" ; + } + display.innerHTML += testStr + "
"; + testStr = "| "; + } +}