You are viewing a single comment's thread. Return to all comments →
**JavaScript Solution : **
function encryption(s) { // Write your code here s = s.trim(); const enc = []; let encripted = ""; const len = s.length; const row = Math.floor(Math.sqrt(len)); const col = Math.ceil(Math.sqrt(len)); s = s.split("") while(s.length){ enc.push(s.splice(0, col)); } for(let i = 0; i < col; i++){ for(let j = 0; j < enc.length; j++){ if(enc[j][i]){ encripted += enc[j][i]; } } encripted += " "; } // console.log(encripted); return encripted; }
Encryption
You are viewing a single comment's thread. Return to all comments →
**JavaScript Solution : **