let v = 0
function test() {
return new Promise(function (resolve, reject) {
if (v > 0) {
resolve('aaa')
} else {
reject('bbb')
}
})
}
let aaa = test()
console.log(aaa)
aaa.then(res => {
console.log(res)
})
let sarr = [
1,2,3,4,5,6,7,8,9,10
]
function atest(arr, aa) {
let newArr = []
let num = aa
for (let i = 0; i < arr.length; i++) {
if (i < num) {
newArr.push(arr[i])
} else {
let longitude = 0
for (let j = 0; j <= num; j++) {
// console.log(arr[i-j])
longitude += arr[i-j]
}
newArr.push(longitude)
}
}
console.log(newArr)
return newArr
}
atest(sarr, 4)
console