Tell us what’s happening:
where could I be going wrong. Please assist. 4 steps are not going through.
Your code so far
let lunches=[];
function addLunchToEnd(lunches,str){
let newArr= lunches.push(str);
console.log(`${str} added to the end of the lunch menu.`);
return lunches
};
addLunchToEnd(lunches,"Tacos");
function addLunchToStart(lunches, str){
let newArr= lunches.unshift(str);
console.log(`${str} added to the start of the lunch menu.`);
return lunches
};
addLunchToStart(lunches, "Chapati");
function removeLastLunch(lunches){
if(lunches.length===0){
console.log(`No lunches to remove.`);
}else{
let lastLunch= lunches.pop();
console.log(`${lastLunch} removed from lunch menu.`);
};
return lunches
};
removeLastLunch([lunches]);
function removeFirstLunch(lunches){if (lunches.length===0){
console.log("No lunches to remove.");
}else{let firstLunch= lunches.shift();
console.log(`${firstLunch} removed from the start of the lunch menu.`);}
return lunches
};
removeFirstLunch(lunches);
function getRandomLunch(lunches){if(lunches.length<1){
console.log("No lunches available.");
}else{
let randomLunch= lunches[Math.floor(Math.random()*lunches.length)];
console.log("Randomly selected lunch:"+randomLunch);}
};
function showLunchMenu(lunches){if (lunches.lenght>=1){
console.log(`Menu items: ${lunches[0]},${lunches[1]}...`)
}else{
console.log("The menu is empty.");
}
}
showLunchMenu(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/135.0.0.0 Safari/537.36
Challenge Information:
Build a Lunch Picker Program - Build a Lunch Picker Program