// Method that performs basic string compression using the counts of repeated characters

function compressStr(str) {
	var output = "", // will return this variable as final compressed string
		currChar = "", // represents character we are searching for in string
		currCount = "", // counts number of times character is repeated
		// maxCount = ""; // maximum count

	// iterate through entire string
	for (i = 0; i < str.length; i++) {
		// if the character we are searching for in string matches the character being looked at
		if ( currChar !== str[i]) {
			output = output + currChar + currCount; // output is sum of the output we have so far plus the character we have been searching for in our string plus the number of times that character is repeated
			// maxCount = Math.max(maxCount, currCount); // choose the larger value between maxCount and currCount
			currChar = str[i]; // move on to the next character
			currCount = 1; // count resets to 1 since we have moved on to the next character
		} else { // if there is a match add to the repeated count
			currCount++;
		}

		output = output + currChar + currCount; // wrap up our final output by doing the same thing to what we did under the scenario where the character we are searching for in string matches the character being looked at
		// maxCount = Math.max(maxCount, currCount);

		return output;
	}
}







@@ -269,25 +269,25 @@
 rrCount = %22%22
-,
+;
  // counts n
@@ -326,45 +326,8 @@
 ated
-%0A%09%09// maxCount = %22%22; // maximum count
 %0A%0A%09/
@@ -491,17 +491,16 @@
 t%0A%09%09if (
- 
 currChar
@@ -719,114 +719,8 @@
 ted%0A
-%09%09%09// maxCount = Math.max(maxCount, currCount); // choose the larger value between maxCount and currCount%0A
 %09%09%09c
@@ -934,18 +934,19 @@
 ++;%0A%09%09%7D%0A
-%0A
 %09
+%7D%0A
 %09output 
@@ -1074,60 +1074,31 @@
 ere 
-the character we are searching for in string
+currChar does not
  match
-es
  the
@@ -1128,80 +1128,146 @@
  at%0A
-%09%09// maxCount = Math.max(maxCount, currCount);%0A%0A%09%09return output;%0A%09%7D%0A%7D%0A%0A%0A%0A%0A%0A
+%0A%09return output;%0A%7D%0A%0A// test cases%0AcompressStr(%22aaaaaaaa%22); // expect to return %22a8%22%0AcompressStr(%22abbcccdddd%22); // expect to return %22a1b2c3d4%22
 %0A

Debug and add test cases