asked 139k views
3 votes
What will be printed to the console after this program runs?

var numbers = [2, 5, 3, 1, 6]

function changeNums(numList, addNum, subtractNum){
for(var i=0; i if(numList[i] % 3 == 0){
numList[i] = numList[i] + addNum;
} else {
numList[i] = numList[i] - subtractNum;
}
}
}

changeNums(numbers, 3, 2);
console.log(numbers);

asked
User Raya
by
8.1k points

1 Answer

4 votes
After the program runs, the console will print out: [0, 3, 1, 7, 4].
answered
User FatDaemon
by
7.9k points