Skip to content

生成数组

js
// 快速实现 [1, 2, ...100],所有你能想到的解

let arr = []
for(let i = 1; i <= 100; i++) {
  arr.push(i)
}
console.log(arr)


let i = 1
let arr1 = []
while(i <= 100){
  arr1.push(i++)
}
console.log(arr1)