Elegant function to "increase" a JavaScript string - for example, turning "aac" into "aad"
A recursive approach is much more elegant in this case:

function inc_str(str) {
  var last = str[str.length - 1],
    head = str.substr(0, str.length - 1);
  if (last === "z") {
    return inc_str(head) + "a";
  } else {
    return head + String.fromCharCode(last.charCodeAt(0) + 1);
  }
}


Making it wrap around for inc_str('z') is left as an exercise for the reader (hint: last becomes undefined).