Tell us what’s happening:
my code doesn’t pass although it works
Your code so far
let lunches = [];
function addLunchToEnd(lunches, newLunch) {
lunches.push(newLunch);
console.log(newLunch + " added to the end of the lunch menu.");
return lunches;
}
console.log(addLunchToEnd(lunches,"Tacos"));
function addLunchToStart(lunches, newLunch2) {
lunches.unshift(newLunch2);
console.log(newLunch2 + " added to the start of the lunch menu.");
return lunches;
}
console.log(addLunchToStart(lunches, "Sushi"));
function removeLastLunch(lunches) {let remove = lunches.pop();
console.log(remove + " removed from the end of the lunch menu.");
if(lunches.length == 0 ) {
console.log("No lunches to remove.")
}
else {
return lunches;}
}
console.log(removeLastLunch(lunches));
function removeFirstLunch(lunches) {
let remove2 = lunches.shift();
console.log(remove2 + " removed from the start of the lunch menu.");
if(lunches.length == 0 ) {
return "No lunches to remove."
}
else {
return lunches;
}}
console.log(removeFirstLunch(lunches));
function getRandomLunch(lunches) {let random = Math.floor(Math.random() * lunches.length);
if (lunches.length == 0) {return "No lunches available."
}
else if (lunches.length !== 0){return "Randomly selected lunch: " + lunches[random]}
}
console.log(getRandomLunch(lunches));
function showLunchMenu(lunches){let shahd = lunches.join(' ,');
if (lunches.length !== 0) {console.log("Menu items: " + shahd);}
else if(lunches.length == 0) {return "The menu is empty.";}
}
console.log(showLunchMenu(lunches));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 Edg/135.0.0.0
Challenge Information:
Build a Lunch Picker Program - Build a Lunch Picker Program