告诉我们发生了什么:
- 要求将([“Stew”,“Soup”,"Toast”,])输了进函数removeLastLunch并记录下来,我函数写好了然后测试这一环节removeLastLunch(这里也不能写东西),不然第1.lunches是用来诸存的空数组。要求就不对了
你目前的代码
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");
addLunchToEnd(lunches,"Tacos");
addLunchToEnd(lunches,"burger");
console.log(lunches);
function addLunchToStart(lunches,string){
lunches.unshift(string);
console.log(string + " added to the start of the lunch menu.")
return lunches;
}
addLunchToStart(lunches,"Sushi")
console.log(lunches);
function removeLastLunch(lunches){
if(lunches.length === 0){
console.log("No lunches to remove.");
}else {
const removeLast = lunches.pop();
console.log(removeLast + " remove from the start of the lunch menu.");
}
return lunches;
}
removeLastLunch
console.log(lunches);
你的浏览器信息:
用户代理是:Mozilla/5.0 (iPhone; CPU iPhone OS 26_6_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/154.0.8037.55 Mobile/15E148 Safari/604.1
挑战信息:
创建午餐选择程序 - 创建一个午餐选择程序