Online Node.js Compiler

const str = 'good'; const encyptString = (str = '') => { const [first, second] = str.split(''); const last = str[str.length - 1]; let res = ''; res += first.charCodeAt(0); res += last; for(let i = 2; i < str.length - 1; i++){ const el = str[i]; res += el; }; res += second; return res; }; console.log(encyptString(str));