<script>
var text = "Test here";
var rotText = "";
const newLine = '<br>';
rotText = rot13(text);
document.write("Org:" + text + newLine);
document.write("Enc:" + rotText + newLine);
document.write("Dec:" + rot13(rotText) + newLine);
function rot13(text){
var rotString = "";
for(var i=0; i< text.length; i++){
var charCode = text.charCodeAt(i);
console.log(charCode);
if(charCode >= 97 && charCode <= 109){
charCode +=13;
}else if(charCode>=110 && charCode<=122){
charCode -=13;
}
var letter = String.fromCharCode(charCode);
rotString = rotString + letter;
}
return rotString;
}
</script>