Tell us what’s happening:
I can’t pass the 24, 28, 29, and 30. Can someone please explain to me where i am getting it wrong?
-
When the input array is not empty, the function getRandomLunch should log a string in the format Randomly selected lunch: [Lunch Item] to the console.
-
When the input array is empty, the function showLunchMenu should log the string “The menu is empty.” to the console.
-
showLunchMenu([“Greens”, “Corns”, “Beans”]) should log “Menu items: Greens, Corns, Beans” to the console.
Your code so far
const lunches = [];
function addLunchToEnd(lunch, item){
lunch.push(item)
console.log(`${item} added to the end of the lunch menu.`)
return lunch;
};
function addLunchToStart(lunches, Sushi){
lunches.unshift(Sushi)
console.log(`${Sushi} added to the start of the lunch menu.`)
return lunches;
}
function removeLastLunch(lunches){
if (lunches.length === 0){
console.log("No lunches to remove.");
}else{
let removedItem = lunches.pop();
console.log(`${removedItem} removed from the end of the lunch menu.`)
}
return lunches
};
function removeFirstLunch(lunches){
if (lunches.length === 0){
console.log("No lunches to remove.")
}else {
let removedFirstStr = lunches.shift();
console.log(`${removedFirstStr} removed from the start of the lunch menu.`)
}
return lunches
};
function getRandomLunch(lunches){
let randomLunch = Math.floor(Math.random() * lunches.length);
if (lunches.lenght === undefined){
console.log("No lunches available.")
}else {
return `Randomly selected lunch: [Lunch Item ${randomLunch}]`
}
};
function showLunchMenu(lunches){
let showMenu = lunches
if (lunches === 0){
console.log("The menu is empty.")
}else {
return `Menu items: ${showMenu}`
}
};
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 Edg/147.0.0.0
Challenge Information:
Build a Lunch Picker Program - Build a Lunch Picker Program