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

Welcome @Paulola to the forum.

We prefer you to create a new post when you have questions about something different than the original post of a thread. I have moved your question to a new thread and gave it an applicable title.

I assume your question is not related to a challenge at freeCodeCamp?

When you say you are confused how to go about it, can you be more specific about what you do not understand how to do?

For example, do you not understand what the end result should be? You said you need to multiple all the odd numbers of an array by 2 but are you supposed to create a new array to store them in or something else?

1 Like

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.