Build a Lunch Picker Program - Build a Lunch Picker Program

Tell us what’s happening:

Why my code can`t pass the test? If I try it with hands it is working.

Your code so far

const lunches = [];

const addLunchToEnd = (arr, item) => {
  arr.push(item)
  console.log(`${item} added to the end of the lunch menu.`)
  return arr;  
}

const addLunchToStart = (arr, item) => {
  arr.unshift(item)
  console.log(`${item} added to the start of the lunch menu.`)
  return arr
}

const removeLastLunch = (arr) => {
  if (arr === undefined){
    console.log("No lunches to remove.")
  } else {
    let ar = arr.pop()
    console.log(`${ar} removed from the end of the lunch menu.`)
    return arr
  }
}

const removeFirstLunch = (arr) => {
  if (arr === undefined){
    console.log("No lunches to remove.")
  } else {
    console.log(`${arr.shift()} removed from the end of the lunch menu.`)
    return arr
  }
}

const getRandomLunch = (arr) => {
  if (arr === undefined){
    return "The menu is empty."
  } else if (arr.length === 0) {
    return "No lunches to remove."
  } else {
   return `Randomly selected lunch: ${arr[Math.round(Math.random() * (arr.lenght - 0) - 0)]}`
  }
}

const showLunchMenu = (arr) => {
  if (arr === undefined) {
    return "The menu is empty."
  } else if (arr.length > 0){
    return `Menu items: ${arr.join(", ")}`
  }
}

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:146.0) Gecko/20100101 Firefox/146.0

Challenge Information:

Build a Lunch Picker Program - Build a Lunch Picker Program

Take a look at what happens in situation from the test, ie:

console.log(removeLastLunch([]));

or

console.log(removeFirstLunch(["Salad", "Eggs", "Cheese"]));

18. removeFirstLunch(["Salad", "Eggs", "Cheese"]) should log the string "Salad removed from the start of the lunch menu." to the console.

but in console

// tests completed
// console output
Salad removed from the end of the lunch menu.
[ 'Eggs', 'Cheese' ]

Are these sentences the same?

My fault. You are right.