FreeCodeCampChina / freecodecamp.cn

FCC China open source codebase and curriculum. Learn to code and help nonprofits.
https://fcc.asia/
Other
37.02k stars 1.38k forks source link

The Code I write wrong deliberately can run and work as well. #647

Open DavidTore opened 4 years ago

DavidTore commented 4 years ago

Challenge [Manipulate Arrays With pop](https://www.freecodecamp.cn/challenges/manipulate-arrays-with-pop#?solution=%2F%2F%20%E4%B8%BE%E4%BE%8B%0Avar%20ourArray%20%3D%20%5B1%2C2%2C3%5D%3B%0Avar%20removedFromOurArray%20%3D%20ourArray.pop()%3B%20%0A%2F%2F%20%E7%BB%8F%E8%BF%87%20pop%20%E6%93%8D%E4%BD%9C%E4%B9%8B%E5%90%8E%EF%BC%8CremovedFromOurArray%20%E7%9A%84%E5%80%BC%E4%B8%BA%203%2C%20ourArray%20%E7%9A%84%E5%80%BC%E4%B8%BA%20%5B1%2C2%5D%0A%0A%2F%2F%20%E5%88%9D%E5%A7%8B%E5%8C%96%E5%8F%98%E9%87%8F%0Avar%20myArray%20%3D%20%5B%5B%22John%22%2C%2023%5D%2C%20%5B%22cat%22%2C%202%5D%5D%3B%0A%0A%2F%2F%20%E8%AF%B7%E5%8F%AA%E4%BF%AE%E6%94%B9%E8%BF%99%E6%9D%A1%E6%B3%A8%E9%87%8A%E4%BB%A5%E4%B8%8B%E7%9A%84%E4%BB%A3%E7%A0%81%0Avar%20removedFromMyArray%20%3D%20myArray%5BmyArray.length%20-%201%5D%3B%0A%0A%0A) has an issue. User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36. Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

// 举例
var ourArray = [1,2,3];
var removedFromOurArray = ourArray.pop(); 
// 经过 pop 操作之后,removedFromOurArray 的值为 3, ourArray 的值为 [1,2]

// 初始化变量
var myArray = [["John", 23], ["cat", 2]];

// 请只修改这条注释以下的代码
var removedFromMyArray = myArray[myArray.length - 1];

When I run the code mentioned above, I surprisedly found that it can work as well ! That is WRONG, because myArray still has a second array. I deliberately remain the second children.

DavidTore commented 4 years ago

And when I switch to the FCC English Version, my code CANNOT PASS the test.