Doubling numbers in an array?

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;
}
1 Like

Hey rstorms,

Remember that in arrays, index starts with 0.

You may want to initialized your variable i to 0.

Happy coding!

Just realized as you typed it haha

1 Like