Tell us what’s happening:
i dont know what’s going on why this code seems to not be going through
Your code so far
const lunches = [];
function addLunchToEnd(arr, str) {
array.push(str);
console.log(`${str} added to the end of the lunch menu.`);
return arr;
}
function addLunchToStart(arr, str) {
array.unshift(str);
console.log(`${str} added to the start of the lunch menu.`);
return arr;
}
function removeLastLunch(arr) {
const arrayLength = arr.length;
const itemNum = arrayLength - 1;
const removedItem = arr(itemNum);
arr.pop();
if (arrayLength === 0)
console.log("No lunches to remove.");
} else {
console.log(`${removedItem} removed from the end of the lunch menu.`);
}
return arr;
}
function removeFirstLunch(arr) {
const arrayLength = arr.length;
const removedItem = arr[0];
arr.shift();
if (array.length === 0) {
console.log("No lunches to remove.");
} else {
console.log(`${removedItem} removed from the start of the lunch menu.`);
}
return arr;
}
function getRandomLunch(arr) {
const arrayLength =arr.length;
const randomIndex = Math.floor(Math.random() * array.length);
const lunchItem = array[randomIndex];
if (array.length === 0) {
console.log("No lunches availabele.");
} else {
console.log(`Randomly selected lunch: ${lunchItem}`);
}
}
const showLunchMenu = arr => {
if (array.length > 0) {
let [first, second, ...rest] = arr;
console.log(`Menu items = ${first}, ${second}, ${rest}`);
} else {
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/146.0.0.0 Safari/537.36 Edg/146.0.0.0
Challenge Information:
Build a Lunch Picker Program - Build a Lunch Picker Program