The article by itself isn't bad, the example is.
You took an example and solved it by slowly reducing it into multiple smaller steps. This, by itself is fine. But you managed to end up with a less readable and over engineered example.
I think the example's objective is to demonstrate the reasoning behind the solution of a problem, and not the most efficient way of writing code. The example is also not using any other method apart from the for loop and the console.log() method. In your case, the inner for loop gets replaced by the repeat method, which adds an extra step of complexity and deviates from the initial objective of the example.
I think your solution could be presented as an extra step in the problem resolution: "improve and make the solution more efficient".
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.
The article by itself isn't bad, the example is.
You took an example and solved it by slowly reducing it into multiple smaller steps. This, by itself is fine. But you managed to end up with a less readable and over engineered example.
You could simply do:
That's a great improvement over the final code! 👍
I think the example's objective is to demonstrate the reasoning behind the solution of a problem, and not the most efficient way of writing code. The example is also not using any other method apart from the
for
loop and theconsole.log()
method. In your case, the innerfor
loop gets replaced by therepeat
method, which adds an extra step of complexity and deviates from the initial objective of the example.I think your solution could be presented as an extra step in the problem resolution: "improve and make the solution more efficient".