JSFiddle - React, Tailwind, and code Playground
by DelightedD0D
HTML
<input type="text"id="old" value="Alex"/ >
<input type="text"id="new" value="Alexander"/ ><br>
<input type="button"id="compare" value="Compare"/ >
JavaScript
$(function(){
$('#compare').click(function() {
compareNames();
});
});
function compareNames(){
var oldName = $('#old').val().split("");
var newName = $('#new').val().split("");
var changeCount = 0;
var testLength = 0;
if(oldName.length > newName.length){
testLength=oldName.length;
}else testLength=newName.length;
for(var i=0;i<testLength;i++){
if(oldName[i]!=newName[i]) {
changeCount++;
}
}
alert(changeCount);
}