Skip to main content
Deno 2 is finally here 🎉️
Learn more
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
function levenshteinDistance
import { levenshteinDistance } from "https://deno.land/std@0.211.0/text/mod.ts";

Calculates the Levenshtein distance between two strings.

Examples

Example 1

import { levenshteinDistance } from "https://deno.land/std@0.211.0/text/levenshtein_distance.ts";
levenshteinDistance("aa", "bb"); // 2

Parameters

str1: string
  • The first string.
str2: string
  • The second string.

Returns

number

The Levenshtein distance between the two strings.