Skip to content

Commit 98cd3a8

Browse files
authored
fix: update the implementation of simple_hash.js and .ts (#1656)
1 parent 35c1885 commit 98cd3a8

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

codes/javascript/chapter_hashing/simple_hash.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function xorHash(key) {
3131
for (const c of key) {
3232
hash ^= c.charCodeAt(0);
3333
}
34-
return hash & MODULUS;
34+
return hash % MODULUS;
3535
}
3636

3737
/* 旋转哈希 */

codes/typescript/chapter_hashing/simple_hash.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function xorHash(key: string): number {
3131
for (const c of key) {
3232
hash ^= c.charCodeAt(0);
3333
}
34-
return hash & MODULUS;
34+
return hash % MODULUS;
3535
}
3636

3737
/* 旋转哈希 */

0 commit comments

Comments
 (0)