Spaces:
Runtime error
Runtime error
// Returns every other value in the array as a new array.function everyOther(arr) {
#30
by
jlapaglCC
- opened
Question:
// Returns every other value in the array as a new array.
function everyOther(arr) {
Answer:
// Returns every other value in the array as a new array.
function everyOther(arr) {
let result = [];
for (let i=0;i< arr.length ;++i){
if ((i+1)%2== 0 )
result[result.length] = arr[i];
}
return result;
}