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));

12th Jan 2017, 12:13 PM
Ugwah chukwuemeka Emmanuel
Ugwah chukwuemeka Emmanuel - avatar
3 Antworten
+ 1
Output: [1,3,5]
13th Jan 2017, 10:00 AM
prof_sadhu
prof_sadhu - avatar
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.
12th Jan 2017, 7:47 PM
Roman Frolov
Roman Frolov - avatar
- 1
if divisible by 2 with a whole number greater than 0, print the number.
12th Jan 2017, 12:50 PM
Louis Milotte
Louis Milotte - avatar