FreeCodeCampChina / FreeCodeCampChina/freecodecamp.cn
结果是shift不是一个函数?
- Dominant language
- CSS
- Stars
- 37.8k
- Forks
- 1.4k
- PR merge metrics
- No merged PRs in 30d
Description
Challenge [Stand in Line](https://www.freecodecamp.cn/challenges/stand-in-line#?solution=function%20queue(arr%2C%20item)%20%7B%0A%20%20arr%20%3D%20arr.push(item)%3B%2F%2F%20%E8%AF%B7%E6%8A%8A%E4%BD%A0%E7%9A%84%E4%BB%A3%E7%A0%81%E5%86%99%E5%9C%A8%E8%BF%99%E9%87%8C%0A%20%20var%20aA%20%3D%20arr.shift()%0A%20%20return%20aA%3B%20%20%2F%2F%20%E8%AF%B7%E4%BF%AE%E6%94%B9%E8%BF%99%E4%B8%80%E8%A1%8C%0A%7D%0A%0A%2F%2F%20%E5%88%9D%E5%A7%8B%E5%8C%96%E6%B5%8B%E8%AF%95%E6%95%B0%E6%8D%AE%0Avar%20testArr%20%3D%20%5B1%2C2%2C3%2C4%2C5%5D%3B%0A%0A%2F%2F%20%E6%8E%A7%E5%88%B6%E5%8F%B0%E8%BE%93%E5%87%BA%0Aconsole.log(%22Before%3A%20%22%20%2B%20JSON.stringify(testArr))%3B%0Aconsole.log(queue(testArr%2C%206))%3B%20%2F%2F%20%E4%BD%A0%E5%8F%AF%E4%BB%A5%E4%BF%AE%E6%94%B9%E8%BF%99%E4%B8%80%E8%A1%8C%E6%9D%A5%E6%B5%8B%E8%AF%95%E4%BD%A0%E7%9A%84%E4%BB%A3%E7%A0%81%0Aconsole.log(%22After%3A%20%22%20%2B%20JSON.stringify(testArr))%3B%0A) 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:
```javascript
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));
```
Contributor guide
Assessment
This issue has not been assessed yet.