DEV Community

Discussion on: String Compression. Facebook interview question.

Collapse
 
tareq12345 profile image
tareq12345 • Edited

What if i changed the while loop to
let char = chars[i]
If(i < chars.length - 1 && chars[i] == chars[i+1]){
Count++
}
else{
count = 1
res+=char + count
}