The Levenshtein distance between two strings is a minimum number
of edits needed to transform one string into the other, with the
allowable edit operations being insertion, deletion,
or substitution of a single character.
Parameters:
| Name | Type | Description |
|---|---|---|
s |
String | Source string. |
t |
String | Target string. |
- Source:
Returns:
Minimum number of edits needed
to transform source string into the target string.
- Type
- Number
Example
var dist = require('path-to-algorithms/src/others/' +
'levenshtein-distance').levenshteinDistance;
console.log(dist('kitten', 'sitting')); // 3