Build a Lunch Picker Program - Build a Lunch Picker Program

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

there is a difference between one and two arguments to console.log, please make sure you are passing one single argument


I don’t understand what you mean. Do you mean I need to use template strings? I tried outputting data using template strings, but nothing changed.

  1. Log the string [Lunch Item] added to the end of the lunch menu. to the console,

The instructions say this entire output needs to be a string. Not a variable and a string.

Yes, or concatenation. Both will work.

After verifying that the output is correct, including spacing, please share your udpated code.

My code:

const addLunchToEnd = (data, line) =>{
  data.push(line);
  console.log(line + " added to the end of the lunch menu.");
  return data;
};

Yes, indeed. I did the output using string concatenation and it worked. Before, when I tried to do this, I forgot about the space, and that’s why it didn’t work. Thank you, the issue is resolved!

1 Like