From 1cffc77bd90ed0999c21fa30b3df460827b9cdcb Mon Sep 17 00:00:00 2001 From: 30secondsofcode <30secondsofcode@gmail.com> Date: Thu, 2 Aug 2018 11:12:32 +0000 Subject: [PATCH] Travis build: 171 --- docs/archive.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/archive.html b/docs/archive.html index 406d71802..66b918536 100644 --- a/docs/archive.html +++ b/docs/archive.html @@ -170,14 +170,14 @@ return `${dt.getDate()}/${dt.getMonth() + 1}/${dt.getFullYear()}`; };
JSONToDate(/Date(1489525200000)/); // "14/3/2017" -
Calculates the Levenshtein distance between two strings.
Calculates the number of changes (substitutions, deletions or additions) required to convert string1 to string2. Can also be used to compare two strings as shown in the second example.
const levenshteinDistance = (string1, string2) => { +
Calculates the Levenshtein distance between two strings.
Calculates the number of changes (substitutions, deletions or additions) required to convert string1 to string2. Can also be used to compare two strings as shown in the second example.
const levenshteinDistance = (string1, string2) => { if(string1.length === 0) return string2.length; if(string2.length === 0) return string1.length; let matrix = Array(string2.length + 1).fill(0).map((x,i) => [i]); matrix[0] = Array(string1.length + 1).fill(0).map((x,i) => i); - for(let i = 1; i <= string2.length; i++){ - for(let j = 1; j<=string1.length; j++){ - if(string2[i-1] === string1[j-1]){ + for(let i = 1; i <= string2.length; i++) { + for(let j = 1; j<=string1.length; j++) { + if(string2[i-1] === string1[j-1]) { matrix[i][j] = matrix[i-1][j-1]; } else{