Skip to content

Instantly share code, notes, and snippets.

@trafficinc
Created November 11, 2019 14:07
Show Gist options
  • Save trafficinc/52810a75e8c90c280998b522b1b4392c to your computer and use it in GitHub Desktop.
Save trafficinc/52810a75e8c90c280998b522b1b4392c to your computer and use it in GitHub Desktop.
Get Difference between Two Strings
function getDiff(a, b) {
var i = 0;
var j = 0;
var result = "";
while (j < b.length) {
if (a[i] != b[j] || i == a.length) {
result += b[j];
} else {
i++;
}
j++;
}
return result;
}
console.log(getDiff("Hello World","Hello This World"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment