Tell us what’s happening:
I passed all steps Is there anything I should improve or fix?
Your code so far
let lunches = [];
let lunchItem = "";
function addLunchToEnd(lunches, lunchItem) {
lunches.push(lunchItem);
console.log(`${lunchItem} added to the end of the lunch menu.`);
return lunches;
}
addLunchToEnd(lunches, "Tacos");
function addLunchToStart(lunches, lunchItem) {
lunches.unshift(lunchItem);
console.log(`${lunchItem} added to the start of the lunch menu.`);
return lunches;
}
addLunchToStart(lunches, "Sushi");
function removeLastLunch(lunches) {
if(lunches.length === 0) {
console.log("No lunches to remove.");
} else {
const removedItemLast = lunches.pop();
console.log(`${removedItemLast} removed from the end of the lunch menu.`);
}
return lunches;
}
removeLastLunch(["Stew", "Soup", "Toast"]);
function removeFirstLunch(lunches) {
if(lunches.length === 0) {
console.log("No lunches to remove.");
} else {
const removedItemFirst = lunches.shift();
console.log(`${removedItemFirst} removed from the start of the lunch menu.`)
}
return lunches;
}
removeFirstLunch(["Sushi", "Pizza", "Burger"]);
function getRandomLunch(lunches) {
if(lunches.length === 0) {
console.log("No lunches available.");
} else {
const randomIndex = Math.floor(Math.random() * lunches.length);
console.log(`Randomly selected lunch: ${lunches[randomIndex]}`);
}
return lunches;
}
function showLunchMenu(lunches) {
if(lunches.length === 0) {
console.log("The menu is empty.");
} else {
console.log(`Menu items: ${lunches.join(", ")}`);
}
return lunches;
}
showLunchMenu(["Greens", "Corns", "Beans"]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.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