From 73e6128a3a5fd5fa68c38095df8003c4a40e5e39 Mon Sep 17 00:00:00 2001 From: Ghassan Nasr Date: Tue, 30 Jun 2020 12:51:29 -0400 Subject: [PATCH 1/5] slide 22 completed --- index.html | 4 +++- js/slide22.js | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index ef9a207..cdc42de 100644 --- a/index.html +++ b/index.html @@ -45,7 +45,9 @@ diff --git a/js/slide22.js b/js/slide22.js index e69de29..844dc35 100644 --- a/js/slide22.js +++ b/js/slide22.js @@ -0,0 +1,11 @@ + +let userInput = -1; +let reEnter = false; +let promptText = "Please enter an integer: "; + +while(userInput <= 0 || userInput >= 100) { + userInput = window.prompt(promptText); + promptText = "Please re-enter: " +} + +alert("The number squared is: " + userInput*userInput); \ No newline at end of file From b7735f6114805aca1dd4f300b620bf81428fdbb5 Mon Sep 17 00:00:00 2001 From: Ghassan Nasr Date: Tue, 30 Jun 2020 13:48:15 -0400 Subject: [PATCH 2/5] slide 23 completed --- index.html | 2 +- js/slide23.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index cdc42de..b526552 100644 --- a/index.html +++ b/index.html @@ -12,7 +12,7 @@ - + diff --git a/js/slide23.js b/js/slide23.js index e69de29..8f54ac2 100644 --- a/js/slide23.js +++ b/js/slide23.js @@ -0,0 +1,12 @@ + +userInput1 = prompt("Please enter L: "); +userInput2 = prompt("Please enter U: "); + +let numbers = []; + +for(num = userInput1; num Date: Tue, 30 Jun 2020 15:16:23 -0400 Subject: [PATCH 3/5] slide 24 completed --- index.html | 8 +++++--- js/slide24.js | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index b526552..ea8a2bf 100644 --- a/index.html +++ b/index.html @@ -11,8 +11,10 @@ + + @@ -45,8 +47,8 @@
-
diff --git a/js/slide24.js b/js/slide24.js index e69de29..64ea4de 100644 --- a/js/slide24.js +++ b/js/slide24.js @@ -0,0 +1,22 @@ +let arr = []; + +for(let i = 0; i < 10; i++) + arr[i] = 1; + +for(let i = 0; i < 10; i++) + console.log(arr[i] + " "); + +let doneAsking = false; + +while(!doneAsking) { + let userIndex = prompt("Give me and index"); + let userValue = prompt("Give me a value"); + if(userIndex < arr.length) + arr[userIndex] = userValue; + else + doneAsking = true; +} + +alert("Goodbye! We could not assign the last value you provided. Index out of range!"); + + \ No newline at end of file From 87ee695e04a24bb2670f85d7f2acf538e9e199f0 Mon Sep 17 00:00:00 2001 From: Ghassan Nasr Date: Tue, 30 Jun 2020 15:53:55 -0400 Subject: [PATCH 4/5] slide 25 completed, and slide 24 corrected. It is actually a continuation of the slide 24 --- index.html | 2 +- js/slide24.js | 4 +--- js/slide25.js | 30 ++++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index ea8a2bf..0138ad3 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,7 @@ - + diff --git a/js/slide24.js b/js/slide24.js index 64ea4de..ace491f 100644 --- a/js/slide24.js +++ b/js/slide24.js @@ -11,12 +11,10 @@ let doneAsking = false; while(!doneAsking) { let userIndex = prompt("Give me and index"); let userValue = prompt("Give me a value"); - if(userIndex < arr.length) + if(userIndex < arr.length && userIndex >= 0) arr[userIndex] = userValue; else doneAsking = true; } alert("Goodbye! We could not assign the last value you provided. Index out of range!"); - - \ No newline at end of file diff --git a/js/slide25.js b/js/slide25.js index e69de29..8a9487b 100644 --- a/js/slide25.js +++ b/js/slide25.js @@ -0,0 +1,30 @@ +function printArray(array) { + let arrStr = ""; + for(let i = 0; i < 10; i++) + arrStr += array[i] + " "; + console.log(arrStr); +} + +let arr = []; + +for(let i = 0; i < 10; i++) + arr[i] = 1; + +printArray(arr); + +let doneAsking = false; + +while(!doneAsking) { + let userIndex = prompt("Give me and index"); + console.log("Input index: " + userIndex); + let userValue = prompt("Give me a value"); + console.log("Input value: " + userValue); + if(userIndex < arr.length && userIndex >= 0) { + arr[userIndex] = userValue; + printArray(arr); + } + else + doneAsking = true; +} + +console.log("Index out of range. Exit!"); From 35770ae2c4655f3f52b90647db24d1a9babd223e Mon Sep 17 00:00:00 2001 From: Ghassan Nasr Date: Tue, 30 Jun 2020 17:15:49 -0400 Subject: [PATCH 5/5] slide 26 completed --- index.html | 2 +- js/slide26.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 0138ad3..a4dac92 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,7 @@ - + diff --git a/js/slide26.js b/js/slide26.js index e69de29..0e008c2 100644 --- a/js/slide26.js +++ b/js/slide26.js @@ -0,0 +1,31 @@ +function printArray(array) { + let arrStr = ""; + for(let i = 0; i < array.length; i++) + arrStr = arrStr + (array[i] + " "); + console.log(arrStr); +} + + +let fibArr = []; +let i = 0; + +let lessThan59 = true; +let nextFib; + +while(lessThan59) { + if (i == 0) + fibArr.push(0); + else if (i == 1) + fibArr.push(1); + else { + nextFib = fibArr[i-1] + fibArr[i-2]; + if (nextFib < 59) + fibArr.push(nextFib); + else + lessThan59 = false; + } + i++; +} + +console.log("The Fibonacci numbers less than 59 are: \n"); +printArray(fibArr); \ No newline at end of file