zainatour / toyProblems

0 stars 1 forks source link

simplify if logic #1

Closed dsernst closed 9 years ago

dsernst commented 9 years ago

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.

dsernst commented 9 years ago

BUMP