It is not a trivial problem.
You should look into Levenshtein distance problem
https://en.wikipedia.org/wiki/Levenshtein_distance
You can search in google for different implementations or use a library like:
https://www.npmjs.com/package/levenshtein
Example:
l = new Levenshtein( 'Zlatan Ibrahimovic', 'Zlatan Ibrahimović')
// l === 1
I used already, and I liked. In my code, I used this one for an experimental proposed.
I don;t care about the result. Because in a long string 4 can be a very good number and in small one 2 it is very bad.
I get to do something like l/Math.max(str1.length, str2.length) then you can make your number and decide wich number is interesting for you.