Languages
[Edit]
EN

JavaScript - calculate Levenshtein distance between strings

20 points
Created by:
mkrieger1
726

In this short article, we would like to show simple JavaScript implementation for the Levenstein distance algorithm.

Levenstein distance algorithm is used to measure the difference between two sequences (e.g. between two strings).

When the algorithm returns 0 it means: compared objects are equal.

Quick solution:

 

Alternative solution

Edit

In this section, you can find some solution that is at the beginning of this article but with more clear variable names.

 

Levenstein distance algorithm with case-insensitive

Edit

It is necessary to wrap the existing algorithm with toLowerCase() or toUpperCase() string transformation.

See also

Edit
  1. JavaScript - check words similarity (fuzzy compare with bigrams)

  2. JavaScript - soundex algorithm implementation

References

Edit
  1. Levenshtein distance - Wikipedia
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

JavaScript - string metrics algorithms

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join