Compare user response with string using javascript for quizz
Compare user response with string using javascript for quizz I have a input field for the user who's listening a music and try to find the correct artist or track name. <input type="search" id="search" class="form-control form-control-lg" name="search" autocomplete="off" autofocus> i would like to it compare with two javascript variables : The problem is to handle human typing errors. ex : "alicia key falin" should return true for the artist and the track name. I have already tried scripts about Hamming Distance and also the fusejs library but i'm not convainced by the result. Actual tests : function hammingDistance(str1, str2) { var dist = 0; str1 = str1.toLowerCase(); str2 = str2.toLowerCase(); for (var i = 0, j = Math.max(str1.length, str2.length); i < j; i++) { if (!str1[i] || !str2[i] || str1[i] !== str2[i]) { dist++; } } return dist; } The objective being to prevent capital, low...