结果是shift不是一个函数?
chenyi369 opened this issue · comments
ChenYi commented
Challenge Stand in Line has an issue.
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36
.
Please describe how to reproduce this issue, and include links to screenshots if possible.
My code:
function queue(arr, item) {
arr = arr.push(item);// 请把你的代码写在这里
var aA = arr.shift()
return aA; // 请修改这一行
}
// 初始化测试数据
var testArr = [1,2,3,4,5];
// 控制台输出
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // 你可以修改这一行来测试你的代码
console.log("After: " + JSON.stringify(testArr));
Xing Liu commented
Lucius commented
function queue(arr, item) {
// 请把你的代码写在这里
arr.splice(arr.length,0,item); //用splice 可解决
return arr.shift(); // 请修改这一行
}