Levenshtein Distance algorithm javascript
String.prototype.levenstein = function(string) {
var a = this, b = string + "", m = [], i, j, min = Math.min;
if (!(a && b)) return (b || a).length;
for (i = 0; i <= b.length; m[i] = [i++]);
for (j = 0; j <= a.length; m[0][j] = j++);
for (i = 1; i <= b.length; i++) {
for (j = 1; j <= a.length; j++) {
m[i][j] = b.charAt(i - 1) == a.charAt(j - 1)
? m[i - 1][j - 1]
: m[i][j] = min(
m[i - 1][j - 1] + 1,
min(m[i][j - 1] + 1, m[i - 1 ][j] + 1))
}
}
return m[b.length][a.length];
}
Also in JavaScript:
- nodejs hello world
- expressjs create encrypted password
- new create react app
- queryselector change alternative
- ajax file upload jquery
- RFC8259 json
- queryselector data attribute
- check if number appears odd number of times in array javascript
- react padding at bottom svg
- javascript remove last element from array
- chrome add a javascript bookmark
- how to check if window size of browser s changed javascript
- jquery remove readonly
- --resolveJsonModule
- angular.min.js version
- discord function promise
- Error: Can't resolve 'fs' webpack
- how to count click events javascript
- javascript 2 decimal float array elements
- how to initialize empty javascript object
- parseint function javascript
- "@testing-library/jest-dom"
- add new key value pair to object javascript
- javascript exeit from loop