Tell us what’s happening:
Having difficulty with the last two steps of this lab. I believe it may have something to do with spacing but not 100% sure. It seems like whatever the issue is, it is the same for both of the last two steps. So close…
Your code so far
let lunches = [];
function addLunchToEnd(arr, str) {
arr.push(str);
console.log(`${str} added to the end of the lunch menu.`);
return arr;
}
console.log(addLunchToEnd(lunches, "Tacos"));
console.log(addLunchToEnd(["Pizza", "Tacos"], "Burger"));
function addLunchToStart(arr, str) {
arr.unshift(str);
console.log(`${str} added to the start of the lunch menu.`);
return arr;
}
console.log(addLunchToStart(lunches, "Sushi"));
addLunchToStart(["Burger", "Sushi"], "Pizza");
console.log(lunches);
function removeLastLunch(arr) {
let removed = arr.pop();
if (arr.length === 0) {
console.log("No lunches to remove.");
}
else {
console.log(`${removed} removed from the end of the lunch menu.`);
}
return arr;
}
console.log(removeLastLunch(["Stew", "Soup", "Toast"]));
function removeFirstLunch(arr) {
let removedStart = arr.shift();
if (arr.length === 0) {
console.log("No lunches to remove.");
}
else {
console.log(`${removedStart} removed from the start of the lunch menu.`);
}
return arr;
}
console.log(removeFirstLunch(["Salad", "Eggs", "Cheese"]));
console.log(removeFirstLunch(["Sushi", "Pizza", "Burger"]));
function getRandomLunch(arr) {
if (arr.length === 0) {
console.log("No lunches available.");
}
else {
let randomIndex = Math.floor(Math.random() * arr.length);
let selectedItem = arr[randomIndex];
let sectedItem = "Lunch Item";
console.log(`Randomly selected lunch: ${selectedItem}`);
}
}
function showLunchMenu(arr) {
if (arr.length === 0) {
console.log("The menu is empty.");
}
else {
console.log(`\"Menu items: ${arr}\"`);
}
return arr;
}
/*console.log(showLunchMenu(["Greens", " Corns", " Beans"]));
console.log(showLunchMenu(["Pizza", " Burger", " Fries", " Salad"]));*/
console.log(showLunchMenu(["Greens", "Corns", "Beans"]));
console.log(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/139.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