scrimba
Note at 0:33
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Note at 0:33
AboutCommentsNotes
Note at 0:33
Expand for more info
index.js
run
preview
console
const btn = document.getElementById("btn")
let food = document.getElementById("food")
const result = document.getElementById("result");

// Tasks:
// - Write the JS to decide the perfect Christmas dinner and render it in the result element. Don't forget to check whether the meal should be vegetarian!

btn.addEventListener("click", christmasCalculator);

function christmasCalculator(){
// console.log(`Clicked`);
let guests = document.getElementById("num-input").value;
let vegetarianInput = document.getElementById("vegetarian-input");
let vegetarianInputTrue = vegetarianInput.checked;
// console.log(guests);

if(vegetarianInputTrue === true) {
// console.log(`true`);
result.textContent = "Your ideal Christmas dinner is Nut roast"
} else {
// console.log(`false`);
if(guests > 5) {
result.textContent = "Your ideal Christmas dinner is Goose"
} else {
result.textContent = "Your ideal Christmas dinner is turkey"
}
}

}

// Dinner suggestions (or choose your own!):
// Vegetarian: nut roast
// 4 people or less: turkey
// 5+ people: goose

// Stretch goals:
// - Add more dietary options.
// - Show recipes when the meal has been selected.

Console
/index.html
LIVE