compress function

// take in a string and compress the string without using a temporary variable // Example compress("aabbccaa") => "a2b2c2a2"

by Augustus Yuan

JavaScript

// take in a string and compress the string without using a temporary variable
// Example compress("aabbccaa") => "a2b2c2a2"
function compress(source) {
	var i=1;
  var currentChar = source[0];
  var currentCount = 1;
  while (source[i] !== currentChar) {
    currentCount++;
    i++;
    
  }
}