Cuéntanos qué está pasando:
Las respuestas tienen que estar en ingles, /y las especificaciones no son claras
Tu código hasta el momento
let lunches = [];
// Agregar al final
function addLunchToEnd(arr, item) {
arr.push(item);
console.log(`${item} added to the end of the lunch menu.`);
return arr;
}
// Agregar al inicio
function addLunchToStart(arr, item) {
arr.unshift(item);
console.log(`${item} added to the start of the lunch menu.`);
return arr;
}
// Eliminar último
function removeLastLunch(arr) {
if (arr.length === 0) {
console.log("No lunches to remove.");
return arr;
}
const removed = arr.pop();
console.log(`${removed} removed from the end of the lunch menu.`);
return arr;
}
// Eliminar primero
function removeFirstLunch(arr) {
if (arr.length === 0) {
console.log("No lunches to remove.");
return arr;
}
const removed = arr.shift();
console.log(`${removed} removed from the start of the lunch menu.`);
return arr;
}
// Obtener aleatorio
function getRandomLunch(arr) {
if (arr.length === 0) {
console.log("No lunches available.");
return;
}
const randomIndex = Math.floor(Math.random() * arr.length);
console.log(`Randomly selected lunch: ${arr[randomIndex]}`);
}
// Mostrar menú
function showLunchMenu(arr) {
if (arr.length === 0) {
console.log("The menu is empty.");
return;
}
console.log(`Menu items: ${arr.join(", ")}`);
}
Información de tu navegador:
El agente de usuario es: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36
Información del Desafío:
Construir un Programa Selector de Almuerzo. - Construir un Programa Selector de Almuerzo