将2从0开始加0.5组成一个新数组[0,0.5,1,1.5,2]
let num = 2; let arr = []; if (num > 0) { for (var i = 0; i < (num*2+1); i++) { let num1 = num - (0.5*i); arr.unshift(num1); } console.log(arr); } else { return false }