Build a Lunch Picker Program - Build a Lunch Picker Program

addLunchToEnd(["Pizza", "Tacos"], "Burger") should return ["Pizza", "Tacos", "Burger"]

I’m confused with this. Is it just asking me to add >console.log(addLunchToEnd([“Pizza”, “Tacos”], “Burger”));
inside the function? when I try that it fails and fails the task above.
do I need to be assigning the other foods somewhere?

Your code so far

const lunches = [];
//add-lunch-to-end-function
function addLunchToEnd(lunches,Tacos){
  lunches.push('Tacos');
    console.log(`${Tacos} added to the end of the lunch menu.`);
    console.log(addLunchToEnd(["Pizza", "Tacos"], "Burger"));

}



























Your browser information:

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

Challenge Information:

Build a Lunch Picker Program - Build a Lunch Picker Program
https://www.freecodecamp.org/learn/full-stack-developer/lab-lunch-picker-program/build-a-lunch-picker-program

This is the first issue I’m seeing with the word Tacos inside as a string. they are only arguments at this time, you could write out all the functions and see how many pass and then the logic part.

To sum it up I just wrote this and the end result was the same as yours.

consts lunches =
function addLunchToEnd (arr, string){
}

no, returning requires a specific keyword that you are not using in your function

Also, just as an aside. You are calling the function inside itself, which will cause an infinite loop. It is recursion without a base case and would result in the error Uncaught RangeError: Maximum call stack size exceeded

Log the function return outside the function, not inside it.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.