Skip to content

Commit dc6946f

Browse files
authored
Update 389-find-the-difference.js
1 parent bc4a1e2 commit dc6946f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

389-find-the-difference.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/**
2+
* @param {string} s
3+
* @param {string} t
4+
* @return {character}
5+
*/
6+
const findTheDifference = function(s, t) {
7+
let xor = 0
8+
for(let i = 0, len = s.length; i < len; i++) xor = xor ^ s.charCodeAt(i) ^ t.charCodeAt(i)
9+
xor = xor ^ t.charCodeAt(t.length - 1)
10+
return String.fromCharCode(xor)
11+
};
12+
13+
// another
14+
115
/**
216
* @param {string} s
317
* @param {string} t

0 commit comments

Comments
 (0)