You want to match two or more strings.
Calculate the edit distance, or number of operations required to transform one string into the other.
You can use either Hirschberg or Wagner–Fischer’s algorithm to calculate a Levenshtein distance. This example uses Wagner–Fischer’s algorithm.
This version of Levenshtein algorithm is linear in memory, quadratic in time.
str.charAt i is preferred here to str[i] because the latter syntax is not supported by some browsers (e.g. IE7).
Finally the optimization of recycling of arrays at the end of the loops is mainly here to demonstrate the syntax of coffeescript for swapping two variables.