JSFiddle - React, Tailwind, and code Playground

by Hassen Charef

JavaScript

let s = `tm bcsv qolfp
f'dmvd xuhm exl tgak
hlrkiv sydg hxm
qiswzzwf qrf oqdueqe
dpae resd wndo
liva bu vgtokx sjzk
hmb rqch fqwbg
fmmft seront sntsdr pmsecq`;

function replace(s) {
  for (let i = 1; i < 27; i++) {
    console.log("i= ", i);
    let result = '';
    for (let c of s) {
      if ((/[a-zA-Z]/).test(c)) {
        result = result + String.fromCodePoint(c.codePointAt(0) + i > 122 ? c.codePointAt(0) + i - 26 : c.codePointAt(0) + i);
      } else {
        result = result + c;
      }
    }
    console.log(result + "\n");
  }
}

replace("a");
replace(s);