String Compression

Run Settings
LanguageJavaScript
Language Version
Run Command
function strCompression(str){ let compressed='' if(str.length===0){ return compressed; } for(let i=0; i<str.length; i++){ let count=1; while(str[i]===str[i+1]){ count++; i++; } compressed+=`${str[i]}${count}` count=1; } return compressed; } console.log(strCompression("aaabccccddeeea"));
Editor Settings
Theme
Key bindings
Full width
Lines