Tell us what’s happening:
// running tests
8. addLunchToStart(lunches, “Sushi”) should log the string “Sushi added to the start of the lunch menu.” to the console.
13. removeLastLunch([“Stew”, “Soup”, “Toast”]) should log the string “Toast removed from the end of the lunch menu.” to the console.
18. removeFirstLunch([“Salad”, “Eggs”, “Cheese”]) should log the string “Salad removed from the start of the lunch menu.” to the console. Please help me out guys! Been working on this for over an hour! ugh!
Your code so far
let lunches =[];
function addLunchToEnd(arr, str){
console.log(`${str} added to the end of the lunch menu.`);
arr.push(str);
return arr;
}
addLunchToEnd(lunches, "Tacos");
console.log(addLunchToEnd(["Pizza " +" Tacos"], "Burgers"));
function addLunchToStart(arr, str){
console.log(`${str} Sushi added to the start of the lunch menu.`)
arr.unshift(str);
return arr;
}
let lunch = ["Burgers", "Sushi"];
addLunchToStart(lunch, "Sushi")
console.log(addLunchToStart(["Burger", "Sushi"], "Pizza"));
function removeLastLunch(deletedFoods){
if (deletedFoods.length === 0) {
console.log("No lunches to remove.");
return deletedFoods;
}
let removedLunch = deletedFoods.pop();
console.log(`${removedLunch} removed from the lunch menu.`);
return(deletedFoods);
}
removeLastLunch(["Stew", "Soup", "Toast"]);
console.log(removeLastLunch(["Sushi", "Pizza", "Noodles"]));
function removeFirstLunch(deleteFood) {
if(deleteFood.length === 0){
console.log("No lunches to remove.");
return deleteFood;
}
let removedLunch = deleteFood.shift();
console.log(`${removedLunch} remove from the start of the lunch menu.`);
return deleteFood;
}
console.log(removeFirstLunch(["Salad", "Eggs", "Cheese"]));
console.log(removeFirstLunch(["Sushi", "Pizza", "Burger"]));
console.log(removeFirstLunch([]));
function getRandomLunch(lunchArray){
if(lunchArray.length === 0){
console.log("No lunch available");
} else {
const randomIndex = Math.floor(Math.random()*lunchArray.length);
console.log(`Randomly selected lunch: ${lunchArray[randomIndex]}`);
}
}
getRandomLunch(["Sandwich", "Salad", "Sushi", "Pizza"]);
getRandomLunch([]);
function showLunchMenu(menuItems){
if(menuItems.length === 0){
console.log("The menu is empty");
}else{
console.log("Menu Items: " + menuItems.join(","));
}
}
showLunchMenu(["Greens", "Corn", "Beans"]);
showLunchMenu(["Pizza", "Burger", "Fries", "Salad"]);
showLunchMenu([]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36 Edg/136.0.0.0
Challenge Information:
Build a Lunch Picker Program - Build a Lunch Picker Program