Skip to content

Instantly share code, notes, and snippets.

View raynoppe's full-sized avatar

Ray Noppe raynoppe

View GitHub Profile
@raynoppe
raynoppe / Levenshtein-spellcheck.js
Created March 10, 2025 10:08
Levenshtein Distance and Spelling Correction
/**
* Calculate Levenshtein distance between two strings
* @param {string} str1 - First string
* @param {string} str2 - Second string
* @returns {number} - The Levenshtein distance
*/
function levenshteinDistance(str1, str2) {
// Create matrix
const matrix = [];