FreeCodeCampChina / freecodecamp.cn

FCC China open source codebase and curriculum. Learn to code and help nonprofits.

Home Page:https://fcc.asia/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

这样为什么会通过,我觉得最后一次是不应该执行,但它确实加入到新数组里了。。。。。。

Black-Dong opened this issue · comments

commented

Challenge Chunky Monkey has an issue.
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.68 Safari/537.36.
Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

function chunk(arr, size) {
  // 请把你的代码写在这里
  var arrT = [];
  for(var i = 0; i < arr.length;i += size){
    arrT.push(arr.slice(i, i+size));
  }
  return arrT;
}

chunk([0, 1, 2, 3, 4, 5], 4);
commented

我混乱了。。。。。。因为i是start,最后一次i还没超出范围