Tell us what’s happening:
I’m unable to pass test #26, which says that the function showLunchMenu should have a single parameter. My function only has a single parameter but it doesn’t pass the test. Any idea why? Thanks in advance. - Dtrizzle
Your code so far
function addLunchToEnd(arr, item) {
arr.push(item);
console.log(`${item} added to the end of the lunch menu.`);
return arr;
}
function addLunchToStart(arr, item) {
arr.unshift(item);
console.log(`${item} added to the start of the lunch menu.`);
return arr;
}
function removeLastLunch(arr) {
if (arr.length > 0) {
let lastItem = arr.pop();
console.log(`${lastItem} removed from the end of the lunch menu.`);
} else {
console.log("No lunches to remove.");
}
return arr;
}
function removeFirstLunch(arr) {
if (arr.length > 0) {
let firstItem = arr.shift();
console.log(`${firstItem} removed from the start of the lunch menu.`);
} else {
console.log("No lunches to remove.");
}
return arr;
}
function getRandomLunch(arr) {
if (arr.length > 0) {
let randomIndex = Math.floor(Math.random() * arr.length);
console.log(`Randomly selected lunch: ${arr[randomIndex]}`);
} else {
console.log("No lunches available.");
}
}
function showLunchMenu(arr = []) {
if (arr.length > 0) {
console.log(`Menu items: ${arr.join(', ')}`);
} else {
console.log("The menu is empty.");
}
}
const lunches = [];
addLunchToEnd(lunches, "Tacos");
addLunchToEnd(["Pizza", "Tacos"], "Burger");
addLunchToStart(lunches, "Sushi");
addLunchToStart(["Burger", "Sushi"], "Pizza");
removeLastLunch(["Sushi", "Pizza"], "Noodles");
removeFirstLunch(["Salad", "Eggs", "Cheese"]);
showLunchMenu();
showLunchMenu(["Greens", "Corns", "Beans"]);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0
Challenge Information:
Build a Lunch Picker Program - Build a Lunch Picker Program