Skip to content

Commit ff613e8

Browse files
togo26parkhojeong
andauthored
Apply suggestion from @parkhojeong
Co-authored-by: Hojeong Park <parkhj062@gmail.com>
1 parent 67296f6 commit ff613e8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

valid-anagram/togo26.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ var isAnagram = function (s, t) {
1414
var isAnagram = function (s, t) {
1515
if (s.length !== t.length) return false;
1616
const sCount = [...s].reduce((acc, cur) => {
17-
acc[cur] = acc[cur] + 1 || 1;
17+
acc[cur] = (acc[cur] ?? 0) + 1;
1818
return acc;
1919
}, {});
2020
const tCount = [...t].reduce((acc, cur) => {
21-
acc[cur] = acc[cur] + 1 || 1;
21+
acc[cur] = (acc[cur] ?? 0) + 1 ;
2222
return acc;
2323
}, {});
2424
return Object.keys(sCount).every(key => sCount[key] === tCount[key]);

0 commit comments

Comments
 (0)