diff --git a/index.js b/index.js index d1ecb27..7f8a0da 100644 --- a/index.js +++ b/index.js @@ -6,8 +6,10 @@ // 2. Write a conditional that returns true if `votingAge` is 18 or older; otherwise, return false. // 3. Log the result to the console. -// let votingAge = /* Your code here */; +// let votingAge = /* Your code here */; +let votingAge = 20; +console.log(votingAge >= 18); /*🏋️‍♂️ Task 2: Variable Value Swap 🔄 */ @@ -17,7 +19,13 @@ // let variableOne = /* Your code here */; // let variableTwo = /* Your code here */; +let variableOne = 5; +let variableTwo = 10; +if (variableTwo > 7) { + variableOne = 15; +} +console.log(variableOne); /*🏋️‍♂️ Task 3: Favorite Number Checker 🔢 */ @@ -26,7 +34,15 @@ // 3. Log the result with a message, e.g., "My favorite number is greater than 10." // let favoriteNumber = /* Your code here */; +let favoriteNumber = 7; +if (favoriteNumber > 10) { + console.log("My favorite number is greater than 10."); +} else if (favoriteNumber < 10) { + console.log("My favorite number is less than 10."); +} else { + console.log("My favorite number is equal to 10."); +} /*🏋️‍♂️ Task 4: Mood Checker 😊😢 */ @@ -37,7 +53,15 @@ // - "So moody!" for any other input // let mood = prompt("How are you feeling today?"); +let mood = prompt("How are you feeling today?"); +if (mood === "happy") { + console.log("Yay me too!"); +} else if (mood === "sad") { + console.log("Aw, cheer up"); +} else { + console.log("So moody!"); +} /*🏋️‍♂️ Task 5: Odd or Even Checker 🔍 */ @@ -46,7 +70,13 @@ // 3. Log whether the number is odd or even, along with the number, to the console. // let num = /* Your code here */; +let num = 42; +if (num % 2 === 0) { + console.log(`${num} is even.`); +} else { + console.log(`${num} is odd.`); +} /*🚀 FIZZBUZZ 🚀 */