code: function levenshtein_distance(a, b) {
    if (!a || a == undefined) {
      return 9999;
    }
    if (!b || b == undefined) {
      return 9999;
    }
    // create a 2 dimensions array
    var m = a.length;
    var n = b.length;
    var dp = new Array(m + 1);
    for (var i = 0; i <= m; i++) {
      dp[i] = new Array(n + 1);
    }
  
    // init dp array
    for (var _i = 0; _i <= m; _i++) {
      dp[_i][0] = _i;
    }
    for (var j = 0; j <= n; j++) {
      dp[0][j] = j;
    }
  
    // dynamic approach
    for (var _i2 = 1; _i2 <= m; _i2++) {
      for (var _j = 1; _j <= n; _j++) {
        if (a[_i2 - 1] !== b[_j - 1]) {
          dp[_i2][_j] = triple_min(1 + dp[_i2 - 1][_j], // deletion
          1 + dp[_i2][_j - 1], // insertion
          1 + dp[_i2 - 1][_j - 1] // replacement
          );
        } else {
          dp[_i2][_j] = dp[_i2 - 1][_j - 1];
        }
      }
    }
    return dp[m][n];
  }
docs: Damerau–Levenshtein distance  implemention ref: https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance