Tell us what’s happening:
I don’t understand why so many tests fail (12, 13, 14, 17, 18, 19, 20, 23, 24, 28, 29). I have run the code on some JavaScript online compilers and it behaves as it should. I can’t find the error… Please, I need help!
Your code so far
const lunches = [];
const addLunchToEnd = (array, string) => {
array.push(string);
console.log(`${string} added to the end of the lunch menu.`);
return array;
};
const addLunchToStart = (array, string) => {
array.unshift(string);
console.log(`${string} added to the start of the lunch menu.`);
return array;
};
const removeLastLunch = array => {
string = array.pop();
if (string) {
console.log(`${string} removed from the end of the lunch menu.`);
} else {
console.log(`No lunches to remove.`);
}
return array;
};
const removeFirstLunch = (array) => {
string = array.shift();
if (string) {
console.log(`${string} removed from the start of the lunch menu.`);
} else {
console.log(`No lunches available.`);
}
return array;
};
const getRandomLunch = array => {
index = Math.floor(Math.random()*(array.length));
if (array.length > 1) {
console.log("Randomly selected lunch: " + array[index]);
} else {
console.log("No lunches available.");
}
}
const showLunchMenu = array => {
if (array.length > 1) {
console.log("Menu items: " + array);
} else {
console.log("The menu is empty.")
}
};
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:137.0) Gecko/20100101 Firefox/137.0
Challenge Information:
Build a Lunch Picker Program - Build a Lunch Picker Program