Skip to content

Commit 6843903

Browse files
committed
1. replace || with ?? for safer nullish coalescing
1 parent 4b4859b commit 6843903

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

valid-anagram/whewchews.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ function isAnagram(s: string, t: string): boolean {
99
for (let i = 0; i <= s.length - 1; i++) {
1010
const sChar = s[i];
1111
const tChar = t[i];
12-
count[sChar] = (count[sChar] || 0) + 1;
13-
count[tChar] = (count[tChar] || 0) - 1;
12+
count[sChar] = (count[sChar] ?? 0) + 1;
13+
count[tChar] = (count[tChar] ?? 0) - 1;
1414
}
1515

1616
// TC: O(N)

0 commit comments

Comments
 (0)