Easy way two double values in Array

I am 17 years old and a young passionate and self-taught frontend web developer and have an intention to become a successful developer. I usually write about JavaScript and Web Development and share some tips in the articles.
Welcome π,
In this article, I will be showing an Easy way to double values in the array
Method - 1
const numbers = [3, 5, 7, 9, 11, 13]
const doubled =[]
for(let i = 0; i < numbers.length; i++){
doubled.push(numbers[i]*2)
}
console.log(doubled)
Method - 2
const numbers = [3, 5, 7, 9, 11, 13]
const doubled = numbers
.filter(n => n !== 0)
.map(n => n * 2);
console.log(doubled)
Feel free to share ideas in the comments...
Follow me at Twitter - @codewithsnowbit Subscribe at YouTube - codewithsnowbit




