Choose a message
Take your time, follow the code and check your understanding.
Move blocks into orderConditions
console.log(message);
else { message = "Sold out"; }if (stock > 0) { message = "Available"; }let message;
const stock = 3;
Your answer3 min · no timer
Drag blocks, or use the arrow buttons. Keep the displayed indentation. This task uses the taught sequence; other equivalent programs may also be valid.
Show solution and explanation
The else must follow its if. The message is printed after a branch assigns it.
const stock = 3;
let message;
if (stock > 0) { message = "Available"; }
else { message = "Sold out"; }
console.log(message);