diff --git a/index.html b/index.html index ef9a207..a4dac92 100644 --- a/index.html +++ b/index.html @@ -11,8 +11,10 @@ + + @@ -45,7 +47,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 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= 0) + arr[userIndex] = userValue; + else + doneAsking = true; +} + +alert("Goodbye! We could not assign the last value you provided. Index out of range!"); 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!"); 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