scrimba
Note at 0:54
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:54
AboutCommentsNotes
Note at 0:54
Expand for more info
index.js
run
preview
console
/**
Task:
- Write the code to help a user choose the perfect Christmas dinner idea
based on the number of people attending.
- Include a checkbox for the user to specify the meal
should be vegetarian-friendly.

Dinner suggestions (or choose your own!):
Vegetarian: Winter Squash Risotto
4 people or less: Ham
5+ people: Turkey

Stretch goals:
- Add more dietary options.
- Show recipes when the meal has been selected.
*/
let dinner = document.getElementById("result")
let checkbox = document.getElementById("vegetarian-input")
let button = document.getElementById("btn")
button.addEventListener("click", function () {
let guestCount = document.getElementById("num-input").value // get the nr of guests from the input field first
dinnerCalc(guestCount);
})

function dinnerCalc(guestnr) {
switch (true) {
case guestnr <= 0:
alert("No guests?")
break
case !checkbox.checked && guestnr <= 4:
console.log(guestnr);
dinner.innerHTML = "töltött tojás"
break
case !checkbox.checked && guestnr > 4:
console.log(guestnr)
dinner.innerHTML = "töltött káposzta"
break
case checkbox.checked:
console.log(guestnr)
dinner.innerHTML = "mákosbejglitmertaztszeretem"
break
}
}


Console
"1"
,
"2"
,
"2"
,
"6"
,
/index.html
LIVE