Tell us what’s happening:
I passed all steps apart from step 30. I have tried debugging it but still couldn’t pass it. Need help.
Your code so far
const lunches =[];
function addLunchToEnd(lunches, item){
lunches.push(item);
console.log(`${item} added to the end of the lunch menu.`)
return lunches;
}
addLunchToEnd(lunches, "Tacos")
function addLunchToStart (lunches, item){
lunches.unshift(item);
console.log(`${item} added to the start of the lunch menu.`)
return lunches;
}
addLunchToStart(lunches, "Sushi")
function removeLastLunch(lunches){
if (lunches.length != 0){
console.log(`${lunches.pop()} removed from the end of the lunch menu.`)
}else{
console.log("No lunches to remove.")
}
return lunches;
}
removeLastLunch(["Stew", "Soup", "Toast"])
function removeFirstLunch(lunches){
if(lunches.length != 0 ){
console.log(`${lunches.shift()} removed from the start of the lunch menu.`)
}else{
console.log("No lunches to remove.")
}
return lunches;
}
removeFirstLunch(["Sushi", "Pizza", "Burger"])
function getRandomLunch(lunches){
if(lunches.length === 0){
console.log("No lunches available.")
}else{
let randomLunch = lunches[Math.floor(Math.random() * lunches.length)]
console.log(`Randomly selected lunch: ${randomLunch}`)
}
return lunches;
}
function showLunchMenu(lunches){
const [lunch1, lunch2, ...rest] = lunches;
if(lunches.length != 0){
console.log(`Menu items: ${lunch1}, ${lunch2}, ${rest}`)
}else{
console.log("The menu is empty.")
}
return lunches;
}
showLunchMenu(["Pizza", "Burger", "Fries", "Salad"])
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0
Challenge Information:
Build a Lunch Picker Program - Build a Lunch Picker Program
https://www.freecodecamp.org/learn/full-stack-developer/lab-lunch-picker-program/build-a-lunch-picker-program