From a41874059b753763ba571f0c52d6954504e4d8e7 Mon Sep 17 00:00:00 2001 From: Aidurus Ali Date: Tue, 17 Dec 2024 20:10:20 -0600 Subject: [PATCH] Finished --- index.js | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 3524ab6..bbc9db6 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,12 @@ // 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 = 20; +if (votingAge >= 18) { + console.log(true); +} else { + console.log(false); +} /*🏋️‍♂️ Task 2: Variable Value Swap 🔄 */ @@ -15,8 +20,13 @@ let votingAge = /* Your code here */; // 2. Write a conditional that changes the value of the first variable if a certain condition with the second variable is met. // 3. Log the new value of the first variable to the console. -let variableOne = /* Your code here */; -let variableTwo = /* Your code here */; +let variableOne = 10; +let variableTwo = 5; + +if (variableTwo < 10) { + variableOne = variableTwo * 2; +} +console.log(variableOne); /*🏋️‍♂️ Task 3: Favorite Number Checker 🔢 */ @@ -25,7 +35,15 @@ let variableTwo = /* Your code here */; // 2. Write a conditional to check if `favoriteNumber` is greater than, less than, or equal to 10. // 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 exactly 10."); +} /*🏋️‍♂️ Task 4: Mood Checker 😊😢 */ @@ -36,7 +54,15 @@ let favoriteNumber = /* Your code here */; // - "Aw, cheer up" if the mood is "sad" // - "So moody!" for any other input + let mood = prompt("How are you feeling today?"); +if (mood.toLowerCase() === "happy") { + console.log("Yay me too!"); +} else if (mood.toLowerCase() === "sad") { + console.log("Aw, cheer up"); +} else { + console.log("So moody!"); +} /*🏋️‍♂️ Task 5: Odd or Even Checker 🔍 */ @@ -45,7 +71,13 @@ let mood = prompt("How are you feeling today?"); // 2. Write a conditional to check if the number is odd or even. // 3. Log whether the number is odd or even, along with the number, to the console. -let num = /* Your code here */; +let num = 12; + +if (num % 2 === 0) { + console.log(`${num} is even.`); +} else { + console.log(`${num} is odd.`); +} /*🚀 FIZZBUZZ 🚀 */