Build a Lunch Picker Program - Build a Lunch Picker Program

Tell us what’s happening:

Help me with this. My removeLastLunch function is showing this error: TypeError: Cannot read proerties of undefined (reading ‘length’).

Your code so far

const lunches = [];
const addLunchToEnd = (lunches, str) => {
let newArr = lunches.push(str);
console.log(`${str} added to the end of the lunch menu.`);
return lunches;
}
console.log(addLunchToEnd(lunches,"Tacos"));
addLunchToEnd(["Pizza", "Tacos"],"Burger"); 
const addLunchToStart = (lunches,str) => {
let newArr = lunches.unshift(str);
console.log(`${str} added to the start of the lunch menu.`);
return lunches;
}
console.log(addLunchToStart(lunches, "Sushi"));
let result = addLunchToStart(["Burger","Sushi"],"Pizza");
console.log(result);
const removeLastLunch = (lunches) => {
if (lunches.length!==1){
  let newArray = lunches.pop();
  console.log(`${newArray} removed from the end of the lunch menu.`);
}else{
  console.log("No lunches to remove.");
}
 return lunches;
}
removeLastLunch();

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 Edg/144.0.0.0

Challenge Information:

Build a Lunch Picker Program - Build a Lunch Picker Program

You did not pass an argument to your function call.

It worked. There’s another error

When the input array is empty, the function removeLastLunch should log the string "No lunches to remove." to the console.

why this condition?
do you want to remove lunches the same way if there are 0 or 5 elements in the array?

and if there is one instead you don’t want to remove?

Well i think using the strictly equal to will help because it tell the function , it has to be empty to appear true. it worked for me