freecodecamp.cn icon indicating copy to clipboard operation
freecodecamp.cn copied to clipboard

使用 for 循环把从 1 到 5 添加进 myArray 中。 求助如下写法

Open KaapoMarcus opened this issue 9 years ago • 2 comments

var myArray = []; for(var i=1;i<6;i++){ //myArray.push(i); /// 标准答案 myArray.unshift(i); ///此处也是按照1到5 加入到数组了。 运行不通过 }

KaapoMarcus avatar Jan 09 '17 06:01 KaapoMarcus

@KaapoMarcus https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift

S1ngS1ng avatar Feb 15 '17 08:02 S1ngS1ng