Count characters in a string
The algorithm is not working quite as you may expect:


   if (result[str[i]] === undefined &amp;&amp; str[i] !== " ") {
        result[str[i].toLowerCase()] = 1;
    } else {
        if (str[i] !== " ") {
            // add one to value at current key
            result[str[i]]++;
        }
    }



If you enter "Hello, World! - Hi!" the two upper case 'H' are only counted as one, because they both evaluate to true in the first if-statement - because you test for an upper case 'H' but save a lower case 'h'.

In the same place you filter spaces out both in true and false, so you could do that as the first thing to do in the loop.

All in all that could be like: 

  for (; i &lt; stringLen; i++) {
    let ch = str[i].toLowerCase();
    if (ch !== " ") {
      if (result[ch] === undefined) {
        result[ch] = 1;
      } else {
        result[ch]++;
      }
    }
  }




Use comments to explain why you do what you do (if not obvious), and not what you do - the code shows that.



The whole ting could also be done like this:

function characterCounter(str) {
  if (!str) {
    return "String input required";
  }

  if (typeof str !== "string") {
    str = str.toString();
    if (typeof str !== "string")
      return "Invalid input";
  }

  const result = {};

  for (var i in str) {
    var ch = str[i].toLowerCase();
    if (ch !== " ") {
      if (result[ch] === undefined) {
        result[ch] = 1;
      } else {
        result[ch]++;
      }
    }
  }
  return result;
}