DEV Community

Discussion on: Simple typing effect pure JS (beginner)

Collapse
 
pentacular profile image
pentacular

The recursiveness of addLetter is interesting.

It's clearly following a recursive flow mediated by a scheduler.

It does not support backtracking, but that's not a requirement.

The main objection I have is that it isn't expressed as a reursive operation.

It should be addLetters, which calls addLetter(first), and schedules addLetters(rest), or terminates.

This would express the recursive decomposition of the task. :)

Collapse
 
ljcdev profile image
ljc-dev

Oh I see what u mean. I've updated the post entirely since but probably haven't made the changes u wanted. I get how addLetter should not be the one that handles the logic behind whether to add or not but I do think this keeps things easier to understand to those who dunno much about recursion. Thanks a lot for the feedback, much appreciated!!