Tell us what’s happening:
Please help me, not sure what I’m doing wrong with the last two steps.
29. showLunchMenu([“Greens”, “Corns”, “Beans”]) should log “Menu items: Greens, Corns, Beans” to the console.
30. showLunchMenu([“Pizza”, “Burger”, “Fries”, “Salad”]) should log “Menu items: Pizza, Burger, Fries, Salad” to the console.
Your code so far
let lunches = [];
function addLunchToEnd(lunches,y) {
lunches.push(y);
console.log(`${y} added to the end of the lunch menu.`)
return lunches;
}
console.log(addLunchToEnd(["Pizza", "Tacos"], "Burger"));
function addLunchToStart(lunches, x) {
lunches.unshift(x);
console.log(`${x} added to the start of the lunch menu.`)
return lunches;
}
console.log(addLunchToStart(["Burger", "Sushi"], "Pizza"));
function removeLastLunch(lunches){
if (lunches.length>0){
let removedItemLast = lunches.pop();
console.log(`${removedItemLast} removed from the end of the lunch menu.`)
}else {
console.log(`No lunches to remove.`)
}
return lunches;
}
console.log(removeLastLunch(['Pizza','Burger','Soup']));
function removeFirstLunch(lunches){
if (lunches.length>0){
let removedItemFirst = lunches.shift();
console.log(`${removedItemFirst} removed from the start of the lunch menu.`)
}else {
console.log(`No lunches to remove.`)
}
return lunches;
}
console.log(removeFirstLunch(['Pizza','Burger','Soup']));
function getRandomLunch(lunches){
if (lunches.length>0){
lunches = lunches[Math.floor(Math.random()*lunches.length)];
console.log(`Randomly selected lunch: ${lunches}`);
} else {
console.log(`No lunches available.`);
}
}
getRandomLunch(['Pizza','Burger','Sushi']);
function showLunchMenu(lunches) {
if (lunches.length>0){
lunches = lunches.join(", ");
console.log(`"Menu items: ${lunches}"`);
} else {
console.log(`The menu is empty.`);
}
}
showLunchMenu(["Greens", "Corns", "Beans"]);
showLunchMenu(["Pizza", "Burger", "Fries", "Salad"]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0
Challenge Information:
Build a Lunch Picker Program - Build a Lunch Picker Program