function rot13(message){ //your code here const lowercase= ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']; const uppercase= ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] const answer = [] for (i=0; i<message.length; i++) { let arr if (message[i]===message[i].toLowerCase()) { arr=lowercase } else { arr=uppercase } let pos = arr.indexOf(message[i]) if (pos=== -1) { answer.push(message[i]) continue } pos += 13 pos = pos % 26 answer.push(arr[pos]) } return answer.join('') }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter