First, build an array with a 0|i length (it will floor the number)
Use the reduce method to loop through the built array. Use the a parameter, which is the response array (initialized as [] and updated at each iteration), and the l parameter which is the current index.
For each iteration, add to the a array an item which is described as follow : Build a l+1-long array, fill it with l+1 (hence, if we are at l=1, the built item will be equal to [2, 2]). Then, use the join method to convert it to a string ('22'in this case)
Finally, once the array is built, use the join method one last time to add line breaks between lines
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.
Well, here we go for some JS oneliner:
It works like this :
0|i
length (it will floor the number)reduce
method to loop through the built array. Use thea
parameter, which is the response array (initialized as[]
and updated at each iteration), and thel
parameter which is the current index.a
array an item which is described as follow : Build al+1
-long array, fill it withl+1
(hence, if we are atl=1
, the built item will be equal to[2, 2]
). Then, use thejoin
method to convert it to a string ('22'
in this case)join
method one last time to add line breaks between lines