Build a Lunch Picker Program - Build a Lunch Picker Program

Tell us what’s happening:

Bottom 4 lines logs two identical pairs of text but function tests will not pass

function showLunchMenu(arr){
if (arr.length===0){
console.log(“The menu is empty.”)
}else{
for (let i = 0; i < arr.length; i++) {
arr[i] = " " + arr[i]
}
console.log(“Menu items:” + arr)
}
}

showLunchMenu([“Greens”, “Corns”, “Beans”])
console.log(“Menu items: Greens, Corns, Beans”)
showLunchMenu([“Pizza”, “Burger”, “Fries”, “Salad”])
console.log(“Menu items: Pizza, Burger, Fries, Salad”)

Your code so far


const lunches =[]



function addLunchToEnd(arr,string){
  arr.push(string)
  console.log(string + " added to the end of the lunch menu.")
  return arr
}

function addLunchToStart(arr, string){
  arr.unshift(string)
  console.log(string + " added to the start of the lunch menu.")
  return arr
}

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

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

function getRandomLunch(arr){
  if (arr.length===0){
    console.log("No lunches available.")
  } else {
    const length=arr.length
    const index = Math.floor(length*Math.random())
    console.log("Randomly selected lunch: " + arr[index])
    return arr[index]
  }
}







function showLunchMenu(arr){
  if (arr.length===0){
    console.log("The menu is empty.")
  }else{
  for (let i = 0; i < arr.length; i++) {
    arr[i] = " " + arr[i]
  }
  console.log("Menu items:" + arr)
  }
}

showLunchMenu(["Greens", "Corns", "Beans"])
console.log("Menu items: Greens, Corns, Beans")
showLunchMenu(["Pizza", "Burger", "Fries", "Salad"])
console.log("Menu items: 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/148.0.0.0 Safari/537.36

Challenge Information:

Build a Lunch Picker Program - Build a Lunch Picker Program

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-lunch-picker-program/66db529d37ad966480ebb633.md at main · freeCodeCamp/freeCodeCamp · GitHub

hello @marticky welcome back to the forum!

the logs may look similar in appearance probably due to the automatic array-to-string conversion here –

but your code is not really formatting the log to include the commas(,) to separate the elements. try including the commas properly.

test with the same array twice please:

const arr = ["Greens", "Corns", "Beans"]
console.log("Menu items: Greens, Corns, Beans")
showLunchMenu(arr);
showLunchMenu(arr);