//-----------------------------------------------------------------------//-----------------------------Caesar Cipher-----------------------------//-----------------------------------------------------------------------//a == 97 z == 122//A == 65 Z == 90constcypher=function(msg,key){letinRange=(number,x,y)=>{if(number>=x&&number<=y){returntrue;}returnfalse;}letnewMsg="";for(leti=0;i<msg.length;i++){letcharUnicode=msg.codePointAt(i);if(inRange(charUnicode,97,122)||inRange(charUnicode,65,90)){newMsg+=String.fromCodePoint(charUnicode+key);}else{newMsg+=msg[i];}}returnnewMsg;}letmessage="This took hella lotta time !";console.log(cypher(message,4));
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
JavaScript