diff --git a/booleans-and-conditionals/exercises/part-1.js b/booleans-and-conditionals/exercises/part-1.js index b829140a07..5ba961089f 100644 --- a/booleans-and-conditionals/exercises/part-1.js +++ b/booleans-and-conditionals/exercises/part-1.js @@ -1,5 +1,16 @@ // Declare and initialize the variables for exercise 1 here: +let engineIndicatorLight = "red blinking" +let spaceSuitsOn = true +let shuttleCabinReady = true +let crewStatus = spaceSuitsOn && shuttleCabinReady +let computerStatusCode = 200 +let shuttleSpeed = 15000 + +TextDecoderStream1 +2 +3 + // BEFORE running the code, predict what will be printed to the console by the following statements: if (engineIndicatorLight === "green") { @@ -9,3 +20,21 @@ if (engineIndicatorLight === "green") { } else { console.log("engines are off"); } + +if (crewStatus === true) { + console.log ("crew ready") +} else {console.log ("crew not ready")} + +if (computerStatusCode === 200) { + console.log ("Please stand by. Computer is rebooting.")} + else if (computerStatusCode === 400) { + console.log ("Success! Computer online.")} + else ("ALERT: Computer Offline!") + + console.log (shuttleSpeed) +if (shuttleSpeed > 17500) { + console.log("ALERT: Escape velocity reached!"); +} else if (shuttleSpeed < 8000) { + console.log ("ALERT: cannot maintain orbit!"); +} else { + console.log ("Stable speed")} \ No newline at end of file diff --git a/errors-and-debugging/exercises/Debugging1stSyntaxError.js b/errors-and-debugging/exercises/Debugging1stSyntaxError.js index 365af5a964..5ac38466ed 100644 --- a/errors-and-debugging/exercises/Debugging1stSyntaxError.js +++ b/errors-and-debugging/exercises/Debugging1stSyntaxError.js @@ -4,8 +4,8 @@ let launchReady = false; let fuelLevel = 17000; -if (fuelLevel >= 20000 { - console.log('Fuel level cleared.'); +if (fuelLevel >= 20000) { + console.log('Fuel level cleared.'); launchReady = true; } else { console.log('WARNING: Insufficient fuel!'); diff --git a/errors-and-debugging/exercises/DebuggingLogicErrors1.js b/errors-and-debugging/exercises/DebuggingLogicErrors1.js index 1ad473f08d..fa4afff094 100644 --- a/errors-and-debugging/exercises/DebuggingLogicErrors1.js +++ b/errors-and-debugging/exercises/DebuggingLogicErrors1.js @@ -1,6 +1,6 @@ // Run this sample code as-is and examine the output. -// Should the shuttle have launched? -// Did it? +// Should the shuttle have launched? No +// Did it? Yes // Do not worry about fixing the code yet, we will do that in the next series of exercises. let launchReady = false; diff --git a/functions/try-it/isPalindrome.js b/functions/try-it/isPalindrome.js index e4565d063a..c2c3e45bc9 100644 --- a/functions/try-it/isPalindrome.js +++ b/functions/try-it/isPalindrome.js @@ -1,7 +1,50 @@ -function reverse(str) { - return str.split('').reverse().join(''); -} +// function reverse(str) { +// return str.split('').reverse().join(''); +// } + +// function isPalindrome(str) { +// return reverse(str) === str; +// } + + +// function sayHello() { +// console.log("Hello, World!"); +// } + +// sayHello(); + +// function sumToN(n) { +// let sum = 0; +// for (let i = 0; i <= n; i++) { +// sum += i; +// } +// return sum; +// } + +// console.log(sumToN(3)); -function isPalindrome(str) { - return reverse(str) === str; +// function plusTwo(num) { +// return num + 2; +// } + +// let a = 2; + +// for (let i=0; i < 4; i++) { +// a = plusTwo(a); +// } + +// console.log(a); + +// function repeater(str) { +// let repeated = str + str; +// console.log(repeated); +// } + +// repeater('Bob'); + +function repeater(str) { + let repeated = str + str; + console.log(repeated); } + +repeater('Bob'); \ No newline at end of file diff --git a/functions/try-it/sayHello.js b/functions/try-it/sayHello.js index 1b6cb75e80..ed7952551f 100644 --- a/functions/try-it/sayHello.js +++ b/functions/try-it/sayHello.js @@ -1,3 +1,16 @@ function sayHello() { console.log("Hello, World!"); } + + + +// let num = 42; + +// function isEven (num) { +// return num % 2 === 0; +// } + +// console.log(isEven(43)); + + + diff --git a/loops/chapter-examples/Reversing-a-String.js b/loops/chapter-examples/Reversing-a-String.js index 9044c0293f..708cf6a0f2 100644 --- a/loops/chapter-examples/Reversing-a-String.js +++ b/loops/chapter-examples/Reversing-a-String.js @@ -5,4 +5,5 @@ for (let i = 0; i < str.length; i++) { reversed = str[i] + reversed; } -console.log(reversed); \ No newline at end of file +console.log(reversed); + diff --git a/loops/chapter-examples/for-Loop-Practice-With-Arrays.js b/loops/chapter-examples/for-Loop-Practice-With-Arrays.js index c463f79138..d9c74bae6b 100644 --- a/loops/chapter-examples/for-Loop-Practice-With-Arrays.js +++ b/loops/chapter-examples/for-Loop-Practice-With-Arrays.js @@ -1,3 +1,9 @@ // create an array variable containing the names +let familyMembers = ["Flavia", "Aldi","Cesar","Cesarito","Kevin"] + // write a for loop that prints each name on a different line + +for (let i = 0; i < familyMembers.length; i++) { + console.log(familyMembers[i]); +} diff --git a/loops/chapter-examples/for-Loop-Practice-With-Strings.js b/loops/chapter-examples/for-Loop-Practice-With-Strings.js index fc5d5885cc..eb1e1b0a44 100644 --- a/loops/chapter-examples/for-Loop-Practice-With-Strings.js +++ b/loops/chapter-examples/for-Loop-Practice-With-Strings.js @@ -1,4 +1,13 @@ // Create a string variable containing your name. +let name = "Aldana" +for (let i = 0; i < name.length; i++) { + console.log(name[i]) +} +// let name = "LaunchCode"; + +// for (let i = 0; i < name.length; i++) { +// console.log(name[i]); +// } // Write a for loop that prints each character in your name on a different line. \ No newline at end of file diff --git a/loops/exercises/for-Loop-Exercises.js b/loops/exercises/for-Loop-Exercises.js index c659c50852..4a87755841 100644 --- a/loops/exercises/for-Loop-Exercises.js +++ b/loops/exercises/for-Loop-Exercises.js @@ -1,16 +1,35 @@ /*Exercise #1: Construct for loops that accomplish the following tasks: a. Print the numbers 0 - 20, one number per line. + + b. Print only the ODD values from 3 - 29, one number per line. c. Print the EVEN numbers 12 to -14 in descending order, one number per line. d. Challenge - Print the numbers 50 - 20 in descending order, but only if the numbers are multiples of 3. (Your code should work even if you replace 50 or 20 with other numbers). */ + for (let i = 0; i < 21; i++) { + console.log(i) + } + +for (let i = -14; i < 12; i = i + 3) { + console.log(i); +} +let words = ['1','5','LC101','blue','42'] + +for (let i=0; i