Nice new kata, Michael!
[...Array(amountOfSheep)] — nowadays, I tend to use Array(amountOfSheep).fill(null) for such cases: Theoretically it should be faster/smaller (while the ... looks definitely cooler!) But I haven't checked that 😊
[...Array(amountOfSheep)]
Array(amountOfSheep).fill(null)
...
Also, a hacky approach 😎:
i=1, 'N sheep...,'.repeat(amountOfSheep).replace(/N/g, () => i++).replace(/,$/,'');
Hey Kostia,
nice solution!
First I used the fill one, but I thought it would be interesting for beginners to read about the widely-used spread operator and see it in action.
fill
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice new kata, Michael!
[...Array(amountOfSheep)]
— nowadays, I tend to useArray(amountOfSheep).fill(null)
for such cases:Theoretically it should be faster/smaller (while the
...
looks definitely cooler!)But I haven't checked that 😊
Also, a hacky approach 😎:
Hey Kostia,
nice solution!
First I used the
fill
one, but I thought it would be interesting for beginners to read about the widely-used spread operator and see it in action.