Doubling numbers in an array?

Doubling numbers in an array?
0

#1

Just an early Saturday morning and finding some trouble already…maybe I really do need that coffee!

if you pass it [1,2,3] then it should return [2,4,6]

function double (arr){
    let newArr = [];
    for(let i = 0; i < arr.length; i++){
        newArr.push(arr[i] * 2);
    }
    return newArr;
}

#2

Hey rstorms,

Remember that in arrays, index starts with 0.

You may want to initialized your variable i to 0.

Happy coding!


#3

Just realized as you typed it haha