Tell us what’s happening:
Greeting! Could someone please give me the answer and explain it to me?
I failed step 4, 8, 13, 18, 24, 29 and 30.
I don’t log the correct answer.
Have a nice day!
Your code so far
let lunches = [];
function addLunchToEnd(array, string) {
array.push(string);
console.log(`"${string} added to the end of the lunch menu."`);
return array;
};
function addLunchToStart(array, string) {
array.unshift(string);
console.log(`"${string} added to the start of the lunch menu."`);
return array;
};
function removeLastLunch(array) {
let suppEnd = array.pop();
if (array.length > 0) {
console.log(`"${suppEnd} removed from to end of the lunch menu."`);
return array;
}
else {
console.log("No lunches to remove.");
return array;
}
};
function removeFirstLunch(array) {
let suppStart = array.shift();
if (array.length > 0) {
console.log(`"${suppStart} removed from the start of the lunch menu."`);
return array;
}
else {
console.log("No lunches to remove.");
return array;
}
};
function getRandomLunch(array) {
let randomNum = Math.floor(Math.random() * (array.length - 1));
let randomLunch = array[randomNum];
if (array.length > 0) {
console.log(`"Randomly selected lunch: ${randomLunch}"`);
}
else {
console.log("No lunches available.");
}
};
function showLunchMenu(array) {
if (array.length > 0) {
return console.log(`"Menu items: ${array.join(', ')}"`);
}
else {
return console.log("The menu is empty.");
}
};
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36
Challenge Information:
Build a Lunch Picker Program - Build a Lunch Picker Program