Tell us what’s happening:
Build a Lunch Picker Program issues on 2nd User Story. I cannot get my code to work correctly. Please help. Thanks!
const lunches = ;
function addLunchToEnd(lunches, string) {
lunches.push(string);
console.log(${string} added to the end of the lunch menu.);
return lunches;
}
addLunchToEnd(lunches, [“Pizza”, “Tacos”], “Burger”)
console.log(lunches);
Your code so far
const lunches = [];
function addLunchToEnd(lunches, string) {
lunches.push(string);
console.log(`${string} added to the end of the lunch menu.`);
return lunches;
}
addLunchToEnd(lunches, ["Pizza", "Tacos"], "Burger")
console.log(lunches);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36 Edg/149.0.0.0
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
Hey @admagee63,
User Story 2 instructs you to create a function that accepts two parameters: an array and a string. You need to add the string to the array passed in as a parameter.
For example:
addLunchToEnd(["Pizza", "Tacos"], "Burger")
In the above code, the array is ["Pizza", "Tacos"] and the string is "Burger".
After the function runs, you should return an updated array, which would be:
["Pizza", "Tacos", "Burger"]
Try the above and paste your code here. If you have any questions, please let us know.
const lunches = [];
function addLunchToEnd(lunches, string) {
lunches.push(string);
console.log(\`${string} added to the end of the lunch menu.\`);
return lunches;
}
addLunchToEnd([“Pizza”, “Tacos”], “Burger”)
console.log([“Pizza”, “Tacos”, “Burger”]);
That is my code now. It seems to have worked. Thank you.
Congratulations on solving the problem, but clean up your code so that you don’t get confused while solving other user stories.
I am still very new at this. What do you mean “clean up my code”?
By code cleaning, I mean removing unused code.
For eg:
Removing below statements
console.log([“Pizza”, “Tacos”, “Burger”]);
Ohhh! Ok, thank you so very much for your help. 
My bad!
@admagee63, please don’t remove
const lunches = [];
I missed it, sorry for that! and I’ve updated my above comment.