Since the algorithm always adds the string's next character to the output variable, this change moves that part above the conditional that checks for odd numbers. This follows the principle of Don't Repeat Yourself, and reduces unnecessary complexity.
This change also uses the + shorthand to concatenate the "-", which is a tiny bit more performant in Chrome (see MDN) and cleaner.
This PR makes no functional changes to the output.
Since the algorithm always adds the string's next character to the output variable, this change moves that part above the conditional that checks for odd numbers. This follows the principle of Don't Repeat Yourself, and reduces unnecessary complexity.
This change also uses the
+
shorthand to concatenate the"-"
, which is a tiny bit more performant in Chrome (see MDN) and cleaner.This PR makes no functional changes to the output.