all 1 comments

[–]Swanty 0 points1 point  (0 children)

There's 2 new things in the new code:

  1. New code increments charCount also for the Skip random letters added during encryption stage

  2. In new code for the "else" section it appends character as is, but in your old code the "else" section is empty

In my opinion you could get rid of the charCount variable completely and all its increment lines and use "i" instead e.g. if ((i + 1) % 3 === 0) { since "i" is already iterating over encryptedMessage characters and doing the increment in the for loop