From d677a29b8bcd838b8c9fa718f673c2817bdc4ad2 Mon Sep 17 00:00:00 2001 From: Nkyo Lio Date: Tue, 30 Jun 2020 14:47:49 -0400 Subject: [PATCH 1/3] last update --- index.html | 15 +++++++++------ js/slide22.js | 5 +++++ js/slide23.js | 16 ++++++++++++++++ js/slide24.js | 22 ++++++++++++++++++++++ js/slide26.js | 10 ++++++++++ 5 files changed, 62 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index ef9a207..87532bb 100644 --- a/index.html +++ b/index.html @@ -4,16 +4,15 @@ - + + + - - - @@ -33,7 +32,9 @@ - + + + The quickest of brown foxes. @@ -45,7 +46,9 @@ diff --git a/js/slide22.js b/js/slide22.js index e69de29..996a3f4 100644 --- a/js/slide22.js +++ b/js/slide22.js @@ -0,0 +1,5 @@ +let userInput; +while(true) { + userInput = window.prompt("Enter a number between 0 and 100"); + if(userInput > 0 && userInput < 100) break; +} \ No newline at end of file diff --git a/js/slide23.js b/js/slide23.js index e69de29..4f31c0f 100644 --- a/js/slide23.js +++ b/js/slide23.js @@ -0,0 +1,16 @@ +let valL = window.prompt("Please enter L:"); +let valU = window.prompt("Please enter U:"); +let output = ""; +valL = parseInt(valL); +valU = parseInt(valU); + +if(valL >= valU) { + console.log("No value within the range"); +} else { + while(valL - valU != 0) { + output += valL + " "; + valL++; + } +} +console.log(output); + diff --git a/js/slide24.js b/js/slide24.js index e69de29..cb0b077 100644 --- a/js/slide24.js +++ b/js/slide24.js @@ -0,0 +1,22 @@ +let myData = new Array(10); + +for(let i = 0; i < myData.length; i++) { + myData[i] = 1; +} +console.log(myData); + +let index; +let value; +while(true) { + index = window.prompt("Enter the index:"); + index = parseInt(index); + + // Breaks if the value is not within 1 and 10 + if(index < 0 || index >= 10) { + break; + } + + value = window.prompt("Enter the value:"); + myData[index] = parseInt(value); + console.log(myData); +} \ No newline at end of file diff --git a/js/slide26.js b/js/slide26.js index e69de29..558bf93 100644 --- a/js/slide26.js +++ b/js/slide26.js @@ -0,0 +1,10 @@ +let arrayFib = new Array(60); +arrayFib[0] = 0; +arrayFib[1] = 1; +console.log("First element: " + arrayFib[0]); +console.log("Second element: " + arrayFib[1]); +for(let i = 2; i < arrayFib.length; i++) { + arrayFib[i] = arrayFib[i -1] + arrayFib[i - 2]; + console.log(i + "th element: " + arrayFib[i]); +} + From b79904c93b72b1f576b644f9e9d69d5b968f466f Mon Sep 17 00:00:00 2001 From: Nkyo Lio Date: Tue, 30 Jun 2020 15:00:39 -0400 Subject: [PATCH 2/3] last update --- js/slide25.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/js/slide25.js b/js/slide25.js index e69de29..cb0b077 100644 --- a/js/slide25.js +++ b/js/slide25.js @@ -0,0 +1,22 @@ +let myData = new Array(10); + +for(let i = 0; i < myData.length; i++) { + myData[i] = 1; +} +console.log(myData); + +let index; +let value; +while(true) { + index = window.prompt("Enter the index:"); + index = parseInt(index); + + // Breaks if the value is not within 1 and 10 + if(index < 0 || index >= 10) { + break; + } + + value = window.prompt("Enter the value:"); + myData[index] = parseInt(value); + console.log(myData); +} \ No newline at end of file From 70268c4300099f17932feec1193f3664afb7ebc0 Mon Sep 17 00:00:00 2001 From: Nkyo Lio Date: Tue, 30 Jun 2020 15:35:46 -0400 Subject: [PATCH 3/3] last update --- index.html | 2 +- js/slide22.js | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 87532bb..645fce7 100644 --- a/index.html +++ b/index.html @@ -47,7 +47,7 @@
- +
diff --git a/js/slide22.js b/js/slide22.js index 996a3f4..3a989d3 100644 --- a/js/slide22.js +++ b/js/slide22.js @@ -1,5 +1,8 @@ -let userInput; +let userInput = window.prompt("Please enter an integer:"); while(true) { - userInput = window.prompt("Enter a number between 0 and 100"); - if(userInput > 0 && userInput < 100) break; + if(userInput > 0 && userInput < 100) { + console.log(Math.pow(parseInt(userInput), 2)); + break; + }; + userInput = window.prompt("Please re-enter:"); } \ No newline at end of file