Build a Lunch Picker Program - Build a Lunch Picker Program

Tell us what’s happening:

Can anyone tell me why it doesn’t pass any of the tests?

Your code so far

let lunches = [];
function addLunchToEnd(lunches, lunchItem){
lunches.push(lunchItem);
console.log(`${lunchItem} added to the end of the lunch menu.`);
return lunches;
}

function addLunchToStart (lunches , lunchItem){
lunches.unshift(lunchItem);{
console.log(`${lunchItem} added to the start of the lunch menu.`)
return lunches;
}


function removeLastLunch (lunches) {
  if(lunches.length == 0){
  return console.log("No lunches to remove.");
}
else {lunches.pop();
console.log(`${lunchItem} removed from the end of the lunch menu.`)
return lunches;
}

function removeFirstLunch (lunches) {
  if(lunches.length == 0){
return console.log("No lunches to remove.")
} else{
lunches.shift();
console.log(`${lunchItem} removed from the start of the lunch menu.`)
return lunches;
}

function getRandomLunch (lunches){
  const randomLunch = Math.floor(Math.random() * lunches.length);
  if(lunches.length == 0){
  console.log(`No lunches available.`);
}else{
  return `Randomly selected lunch: ${randomLunch}`;}
}

function showLunchMenu (lunches){
  if (lunches.length == 0){
    return "The menu is empty.";
  } else{
    return console.log(`Menu items: ${lunches}`);
  }
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36

Challenge Information:

Build a Lunch Picker Program - Build a Lunch Picker Program

you have a syntax error

if you right click and choose Format document you should see how all the functions start getting more and more indented

Ok, I got everything passed except for the last two tests and I don’t get how to make both work. Can anyone help me?

function showLunchMenu(lunches){

let [lunch1, lunch2, …rest] = lunches

if(lunches.length == 0){

return console.log("The menu is empty.");}

else{

  return console.log(\`Menu items: ${lunch1}, ${lunch2}, ${rest}\`)

}

}

can you please format your code? if you let the editor do that for you it adds random escaping characters and it’s difficult to know what you wrote and what you didnt

When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').