We're a place where coders share, stay up-to-date and grow their careers.
Did anybody talk about oneliner?
f=(i)=>[...Array(i)].map((_,i)=>`${i+1} sheep... `).join``
And the results
f(10); // "1 sheep... 2 sheep... 3 sheep... 4 sheep... 5 sheep... 6 sheep... 7 sheep... 8 sheep... 9 sheep... 10 sheep... "
This is sweet. Something similar but with more Array and less map:
Array
map
const f = i => Array.from(Array(i), (_, i) => `${i + 1} sheep... `).join``
or
const f = i => Array.from({ length: i }, (_, i) => `${i + 1} sheep... `).join``
Did anybody talk about oneliner?
And the results
This is sweet. Something similar but with more
Array
and lessmap
:or