//sample solution
function stringDistance(str1, str2){
/*Complete the code below to go through two strings
and return the number of letters that do not match.
Assume both str1 and str2 have the same length. **/
var numMismatch = 0;
var index = 0;
while (index<str1.length) {
if (str1.charAt(index)!==str2.charAt(index)) {
numMismatch++;
}
/*your code here to increment index*/
index++;
}
return numMismatch;
}
//test
stringDistance("dog","cat");
No comments:
Post a Comment