Javascript Nested Conditionals Hacks Below

Hack 1: Write Javascript pseudocode to decide whether or not to study for an exam.

Check the following conditions:

You must have your study materials (books, notes, etc.).
You must have a quiet place to study.
You must not be feeling too tired.

If all conditions are met, print that you are ready to study.
If you don’t have a quiet place, suggest finding a quiet location.
If you are too tired, suggest taking a nap or resting first.
If you don’t have your study materials, print that you need to gather them first.
Hack 2: Write Javascript code deciding whether or not you can bake a cake.

Check the following conditions:

You must have all the ingredients (flour, eggs, sugar).
Your oven must be working.
You must have at least 2 hours to bake and cool the cake.

If all conditions are true, print that you can start baking.
If you don't have enough time, print that you need to find more time.
If the oven is not working, print that you need to fix or replace the oven.
If you don't have all the ingredients, print what you are missing.
Hack 3: Write Javascript code to determine whether or not to go camping.

Use the following conditions:

The weather must be clear.
You must have a tent.
You must have enough food and water for the trip.

If all conditions are met, print that you are ready to go camping.
If you don’t have a tent, print that you need to buy or borrow a tent.
If you don’t have enough food and water, print that you need to pack more.
If the weather is not clear, print that it’s not a good time for camping.

Javascript Quiz

Question 1:

What will be the output of the following code?

let score = 85;
let hasExtraCredit = false;

if (score >= 90) {
    console.log("Grade: A");
} else {
    if (score >= 80) {
        if (hasExtraCredit) {
            console.log("Grade: A");
        } else {
            console.log("Grade: B");
        }
    } else {
        console.log("Grade: C or below");
    }
}

A. Grade: A B. Grade: B C. Grade: C or below

Question 2:

Given the following code, what will be printed if age = 30 and isMember = true?

let age = 30;
let isMember = true;

if (age < 18) {
    console.log("Child discount applies.");
} else {
    if (isMember) {
        console.log("Member discount applies.");
    } else {
        console.log("No discount available.");
    }
}

A. Child discount applies. B. Member discount applies. C. No discount available.

Question 3:

What will be the output of the following code?

let day = "Saturday";
let weather = "sunny";

if (day === "Saturday") {
    if (weather === "sunny") {
        console.log("Let's go to the park!");
    } else {
        console.log("Let's stay indoors.");
    }
} else {
    console.log("It's a weekday, time to work.");
}

A. Let’s go to the park! B. Let’s stay indoors. C. It’s a weekday, time to work.