i am trying to solve a code challenge that asks me to fill an array with the value passed as an argument in a function.
For example = fizzBuzz(10)
should return an Array with 10 slots and for each slot increment 1
[0, 1, 2, 3 ,4, 5, 6, 7, 8, 9, 10]
i have tried with a loop and with the fill method but i am having difficulties on this.
This is the first step of the algorithm. Can someone help me ?
Here is my last attempt:
function fizzbuzz(n) {
// Write your code here
const array = new Array(n)
for(let i = 0; i < n; i++) {
array.fill(n, 0))
}
return array
}
This wont work cause the fill method is only called once for every slot i guess. Can someone help me ?
I have tried with the forEach method, fill method and with a loop, but i am unable to solve the first step of this algorithm.
I need nelp solving the first step of this algorithm.