Bug Issue with Output in Problem 443. String Compression

There seems to be an issue with the Output on this problem. As seen in my code a console log of the return statement is coded right before a return statement with identical code, yet they yield two different results (images). The console is reflecting the expected result (seen in the stdout), but the output is not.

var compress = function(chars) {
    
    //  PLACEHOLDER TO PUSH COMPRESSED STRING CHARACTERS IN
    let compressed = '';
    
    //  INITIAL CHARACTER COUNT IS 1 FOR EACH CHARACTER
    let count = 1;
    
    //  ITERATE OVER STRING
    for(let i=0; i < chars.length; i++){
        //  VARIABLES FOR THE CURRENT CHAR AND THE NEXT CHAR TO COMPARE TO
        let currChar = chars[i];
        let nextChar = chars[i+1];
        //  IF THE CURRENT AND NEXT CHARS ARE EQUAL, INCREASE THE COUNT FOR THAT CHAR BY 1
        if(currChar === nextChar){
            count++
        } else {
            //  OTHERWISE, IF CURRENT AND NEXT CHAR ARE NOT EQUAL, AND COUNT IS ONLY 1,
            //  ADD THE CHAR TO THE EXISIING COMPRESSED STRING
            if(count === 1){
                compressed += currChar
            } else {
                // BUT IF THEY AREN'T EQUAL AND COUNT IS MORE THAN ONE,
                // ADD THE CHAR PLUS THE COUNT AS A STRING TO THE COMPRESSED STRING
                compressed += currChar + count.toString()
                count = 1
			} 
		} 
	}
    
    console.log(compressed.split(''))
    return compressed.split('')
};

image

Comments (1)