Skip to content
Advertisement

I try to build ROT 13 cipher in JavaScript, I did it but output not shown in console please check what’s wrong in it

A common modern use is a ROT13 cipher, where the values of the letters are shifted by 13 places. Thus ‘A’ ↔ ‘N’, ‘B’ ↔ ‘O’, and so on.

JavaScript

Advertisement

Answer

Fixed your code, look at lines 12 and 15 I believe:

JavaScript

I would also use map type object instead of 2 arrays:

JavaScript

You can find your substitute letter like so:

JavaScript

No need to match indexes.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement