Need help with multiplying odd numbers in array by 2

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

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:

  1. You’ll need to filter out the odd numbers and store them in an array.
  2. 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.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.