Tell us what’s happening:
I’m having trouble getting tests 4, 8, 13, and 18 to pass with output to the log. Can you tell me what I’m doing wrong? The console output is correct.
Your code so far
const addLunchToEnd = (data, line) =>{
data.push(line);
console.log(line, "added to the end of the lunch menu.");
return data;
};
const addLunchToStart = (data, line)=>{
data.unshift(line);
console.log(line,"added to the start of the lunch menu.")
return data;
};
const removeLastLunch = (data)=>{
if (data.length){
let line = data.pop();
console.log(line,"removed from the end of the lunch menu.")
return data;
}else{
console.log("No lunches to remove.");
}
return data;
};
const removeFirstLunch = (data)=>{
if (data.length){
let line = data.shift();
console.log(line,"removed from the start of the lunch menu.")
return data;
}else{
console.log("No lunches to remove.");
}
return data;
};
const getRandomLunch = (data) =>{
if (data.length){
const randomIndex = Math.floor(Math.random() * lunches.length);
const lunchItem = lunches[randomIndex];
console.log("Randomly selected lunch:", lunchItem);
}else{
console.log("No lunches available.");
}
};
const showLunchMenu = (data) =>{
if (data.length){
let [first,second ] = data;
console.log(`Menu items:${first},${second}`);
}
else{
console.log("The menu is empty.");
}
};
let lunches = [];
console.log(addLunchToEnd(lunches, "Tacos"));
console.log(addLunchToEnd(["Pizza", "Tacos"], "Burger"));
console.log(addLunchToStart(lunches, "Sushi"));
console.log(addLunchToStart(["Burger", "Sushi"], "Pizza"));
console.log(removeLastLunch(["Stew", "Soup", "Toast"]));
console.log(removeLastLunch(["Sushi", "Pizza", "Noodles"]));
console.log(removeFirstLunch(["Salad", "Eggs", "Cheese"]));
console.log(removeFirstLunch(["Sushi", "Pizza", "Burger"]));
console.log(getRandomLunch(lunches));
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/144.0.0.0 Safari/537.36
Challenge Information:
Build a Lunch Picker Program - Build a Lunch Picker Program