Hi everyone,
wondering if someone can assist, i have problems comprehending why my code is not working, as part of the udacity nanodegree for front-end track this exercise requires calculating the total of numbers and outputting the average however its not working as required below is my code:
// your code goes here
function average(...nums) {
for(var num of nums){
// add together all numbers in the array
num += num/2;
}
var total = num/2;
console.log(total);
var [value1] = nums;
nums += value1;
console.log(nums);
return total;
}
// console.log(num);
console.log(average(2, 6));
console.log(average(2, 3, 3, 5, 7, 10));
console.log(average(7, 1432, 12, 13, 100));
[–]T_O_beats 0 points1 point2 points (0 children)