function distance(
  a,
  b,
) {
  let d = initMatrix(a, b);
  for (var i = 1; i <= a.length; i++) {
    let cost;
    for (let j = 1; j <= b.length; j++) {
      if (a.charAt(i - 1) === b.charAt(j - 1)) {
        cost = 0;
      } else {
        cost = 1;
      }
      d[i][j] = Math.min.apply(null, [
        d[i - 1][j] + 1,
        d[i][j - 1] + 1,
        d[i - 1][j - 1] + cost,
      ]);
      damerau(i, j, a, b, d, cost);
    }
  }
  return d[a.length][b.length];
}
/** Get the Damerau-Levenshtein distance between 2 strings */
Get the Damerau-Levenshtein distance between 2 strings
Get the Damerau - Levenshtein distance between 2 strings
function distance(
  a,
  b,
) {
  let d = initMatrix(a, b);
  for (var i = 1; i <= a.length; i++) {
    let cost;
    for (let j = 1; j <= b.length; j++) {
      if (a.charAt(i - 1) === b.charAt(j - 1)) {
        cost = 0;
      } else {
        cost = 1;
      }
      d[i][j] = Math.min.apply(null, [
        d[i - 1][j] + 1,
        d[i][j - 1] + 1,
        d[i - 1][j - 1] + cost,
      ]);
      damerau(i, j, a, b, d, cost);
    }
  }
  return d[a.length][b.length];
}
function distance ( a , b , ) { let d = initMatrix ( a , b ) ; for ( var i = 1 ; i <= a . length ; i ++ ) { let cost ; for ( let j = 1 ; j <= b . length ; j ++ ) { if ( a . charAt ( i - 1 ) === b . charAt ( j - 1 ) ) { cost = 0 ; } else { cost = 1 ; } d [ i ] [ j ] = Math . min . apply ( null , [ d [ i - 1 ] [ j ] + 1 , d [ i ] [ j - 1 ] + 1 , d [ i - 1 ] [ j - 1 ] + cost , ] ) ; damerau ( i , j , a , b , d , cost ) ; } } return d [ a . length ] [ b . length ] ; }
Get the Damerau-Levenshtein distance between 2 strings
Get the Damerau - Levenshtein distance between 2 strings