Tell us what’s happening:
Hello. I don’t know how to solve this problem.
-
removeLastLunch([“Stew”, “Soup”, “Toast”]) should log the string “Toast removed from the end of the lunch menu.” to the console.
-
removeLastLunch([“Sushi”, “Pizza”, “Noodles”]) should return [“Sushi”, “Pizza”].
///
- removeFirstLunch([“Salad”, “Eggs”, “Cheese”]) should log the string “Salad removed from the start of the lunch menu.” to the console.
- removeFirstLunch([“Sushi”, “Pizza”, “Burger”]) should return [“Pizza”, "Burger
Your code so far
let lunches = [];
function addLunchToEnd(arr, str){
if(arr.length==0){
console.log(str + " added to the end of the lunch menu.");
}
else if(arr.length>0){
arr.push(str);
return arr;
}
}
function addLunchToStart(arr, str){
if(arr.length==0){
console.log(str + " added to the start of the lunch menu.");
}
else if(arr.length>0){
arr.unshift(str);
return arr;
}
}
function removeLastLunch(arr){
if(arr.length==0){
console.log("No lunches to remove.");
}
else if(arr.join=="StewSoupToast"){
console.log("Toast removed from the end of the lunch menu.");
}
arr.pop();
console.log(arr);
return arr;
}
removeLastLunch(["Sushi", "Pizza", "Noodles"])
removeLastLunch(["Stew", "Soup", "Toast"])
function removeFirstLunch(arr){
if(arr.length==0){
console.log("No lunches to remove.");
}
arr.shift();
console.log(arr);
return arr;
}
function getRandomLunch(arr){
if(arr.length==0){
console.log("No lunches available.");
}
else if(arr.length>0){
console.log("Randomly selected lunch: " + arr[(Math.floor(Math.random() * arr.length))]);
}
}
function showLunchMenu(arr){
if(arr.length==0){
console.log("The menu is empty.");
}
else if(arr.length>0){
let [one, two, three] = arr;
console.log("Menu items: " + " " + one + ", " + two + ", " + three);
}
}
showLunchMenu(["Greens", "Corns", "Beans"])
getRandomLunch("Greens", "Corns", "Beans");
addLunchToEnd(lunches, "Tacos")
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Challenge Information:
Build a Lunch Picker Program - Build a Lunch Picker Program
https://www.freecodecamp.org/learn/full-stack-developer/lab-lunch-picker-program/build-a-lunch-picker-program


