Tell us what’s happening:
i have a problem with the last function showLunchMenu , but the output looks correct , idk
Your code so far
let lunches = [];
function addLunchToEnd(array,string){
array.push(string);
console.log(`${string} added to the end of the lunch menu.`);
return array;
}
function addLunchToStart(array,string){
array.unshift(string);
console.log(`${string} added to the start of the lunch menu.`);
return array;
}
function removeLastLunch(array){
const r = array.pop();
if(array.length === 0){
console.log("No lunches to remove.");
}
else{
console.log(`${r} removed from the end of the lunch menu.`);
}
return array;
}
function removeFirstLunch(array){
const r = array.shift();
if(array.length === 0){
console.log("No lunches to remove.");
}
else{
console.log(`${r} removed from the start of the lunch menu.`);
}
return array;
}
function getRandomLunch(array){
const random = Math.floor(Math.random()*array.length);
if(array.length === 0){
console.log("No lunches available.");
}
else{
console.log(`Randomly selected lunch: ${array[random]}`);
}
}
function showLunchMenu(array){
if(array.length === 0){
console.log("The menu is empty.");
}
else{
console.log(`Menu items : ${array.join(", ")}`);
}
}
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/143.0.0.0 Safari/537.36
Challenge Information:
Build a Lunch Picker Program - Build a Lunch Picker Program