Tell us what’s happening:
Steps 29 and 30 don’t pass even though my code produces the expected output. I have tried every solution I can find. I will appreciate any guidance on this problem.
Your code so far
let lunches = [];
let lunchitems=[...lunches]
function addLunchToEnd(lunches, string) {
lunches.push(string);
console.log(`${string} added to the end of the lunch menu.`)
return lunches;
}
function addLunchToStart(lunches, string) {
lunches.unshift(string);
console.log(`${string} added to the start of the lunch menu.`)
return lunches;
}
function removeLastLunch(lunches) {
if (lunches.length > 0) {
let removedItemLast = lunches.pop();
console.log(`${removedItemLast} removed from the end of the lunch menu.`);
} else {
console.log("No lunches to remove.");
}
return lunches;
}
function removeFirstLunch(lunches) {
if (lunches.length > 0) {
let firstItem = lunches.shift();
console.log(`${firstItem} removed from the start of the lunch menu.`);
return lunches;
} else {
console.log("No lunches to remove.");
}
return lunches;
}
function getRandomLunch(lunches) {
if (lunches.length > 0) {
lunches = lunches[Math.floor(Math.random() * lunches.length)];
console.log(`Randomly selected lunch: ${lunches}`);
}
else {
console.log("No lunches available.");
}
return lunches;
}
const showLunchMenu = (lunches) => {
if (lunches.length > 0) {
console.log(`"Menu items: ${lunches}"`);
}
else {
console.log("The menu is empty.");
}
}
showLunchMenu(`${["Greens"," Corns", " Beans"]}`);
showLunchMenu(`${["Pizza", "Burger", "Fries", "Salad"]}`);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36
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