Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 37 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 🔄 */
Expand All @@ -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 🔢 */
Expand All @@ -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 😊😢 */
Expand All @@ -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 🔍 */
Expand All @@ -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 🚀 */
Expand Down