Write a function that takes in two peices of text and then compares them for differences, highlighting the changes parts in green color.
var str1 = "This is string one"; var str2 = "This is string two"; function colorDiff(str1, str2){ var i = 0; var resultString = ""; while (i < str1.length || i < str2.length) { if (str1[i] !== str2[i]){ resultString += "<span style='color:green'>" + str2[i] + "</span>"; } else { resultString += str2[i]; } i++; } return resultString; } colorDiff(str1, str2);