Tell us what’s happening:
I am having trouble with tests #12 & #13 … so far
Both relate to the removeLastLunch function - i’m logging the results as i go and they appear to be correct
Your code so far
let lunches = [];
function addLunchToEnd(arr, str) {
lunches = [...arr];
lunches.push(str);
console.log(str + " added to the end of the lunch menu.");
return lunches;
}
function addLunchToStart(arr, str) {
lunches = [...arr];
lunches.unshift(str);
console.log(str + " added to the start of the lunch menu.");
return lunches;
}
function removeLastLunch(arr) {
lunches = [...arr];
console.log(lunches);
const removeLast = lunches.pop();
console.log(lunches);
console.log(removeLast);
console.log(lunches.length);
if (lunches.length === 0) {
console.log("No lunches to remove.")
} else {console.log(removeLast + " removed from the end of the lunch menu.")}
return lunches;
}
removeLastLunch(["Stew", "Soup", "Toast"])
function removeFirstLunch(arr) {
const removeFirst = lunches.shift();
if (removeFirst > 0) {
console.log(removeFirst + " removed from the start of the lunch menu.")
} else {console.log("No lunches to remove.")}
return lunches;
}
function getRandomLunch(arr) {
const randomElement = lunches[Math.floor(Math.random() * lunches.length)];
if (randomElement > 0) {
console.log("Randomly selected lunch: " + randomElement)
} else {console.log("No lunches available.")}
return lunches;
}
function showLunchMenu(arr) {
const [...rest] = lunches
if (lunches > 0) {
console.log("Menu items: " + rest)
} else {console.log("The menu is empty.")}
}
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 Edg/139.0.0.0
Challenge Information:
Build a Lunch Picker Program - Build a Lunch Picker Program