Hey everyone! I have been getting this exercise wrong, I’m to write while loop that multiplies all the odd numbers that occur in an array by 2. I’m confused how to go about it. Thank you
let arr = [1, 2, 4, 5, 6, 8, 9, 8, 7, 8, 4];
console.log(arr);
I’m confused about the codes, how to write it in proper way
udaaff
June 21, 2022, 8:18am
4
Just write in any way you can, and then we may help you to rewrite it in the proper way.
Yeah, he is right. Do something, first, we’ll take it from there.
But here is a hint:
You’ll need to filter out the odd numbers and store them in an array.
loop through the array and multiply each item in the array by 2.
To filter, use modulo operator or filter method.
Loop using while or for loop.
And, you should arrive at your desired result.
system
Closed
December 20, 2022, 10:02pm
8
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.