function sum(arr,i){for(let j=0,sum=0;j<arr.length;j++){if(j>i){return sum}
sum+=arr[j]
}
return sum
}
sum([1,2,3,4],1)—3
function sum(arr,i){for(let j=0,sum=0;j<arr.length;j++){if(j>i){return sum}
sum+=arr[j]
}
return sum
}
sum([1,2,3,4],1)—3