javascript find similar strings

Solutions on MaxInterview for javascript find similar strings by the best coders in the world

showing results for - "javascript find similar strings"
Emmanuel
17 Feb 2019
1function similarity(s1, s2) {
2  var longer = s1;
3  var shorter = s2;
4  if (s1.length < s2.length) {
5    longer = s2;
6    shorter = s1;
7  }
8  var longerLength = longer.length;
9  if (longerLength == 0) {
10    return 1.0;
11  }
12  return (longerLength - editDistance(longer, shorter)) / parseFloat(longerLength);
13}