0
Pls i need a clear interpretation of this code?
function f(a){ var arr = [] var i = 0; while (i < a.length ){ if(a[i]%2!=0){arr.push(a[i]);} i++; } return arr; } var a= [1,4,3,5]; document.write(f(a));
3 Respuestas
+ 1
Output:
[1,3,5]
0
This function takes number from a[], then takes modulus of 2, and if remainder is not 0, it will add this number to array and after processing all values it will return result array.
- 1
if divisible by 2 with a whole number greater than 0, print the number.