From 98cd3a8076f93b18d17a29a6273cf47886822b65 Mon Sep 17 00:00:00 2001 From: AsaoOoo0o0o <113121152+AsaoOoo0o0o@users.noreply.github.com> Date: Tue, 25 Feb 2025 04:54:48 +0800 Subject: [PATCH] fix: update the implementation of simple_hash.js and .ts (#1656) --- codes/javascript/chapter_hashing/simple_hash.js | 2 +- codes/typescript/chapter_hashing/simple_hash.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/codes/javascript/chapter_hashing/simple_hash.js b/codes/javascript/chapter_hashing/simple_hash.js index 5c2a65409..4287515b3 100644 --- a/codes/javascript/chapter_hashing/simple_hash.js +++ b/codes/javascript/chapter_hashing/simple_hash.js @@ -31,7 +31,7 @@ function xorHash(key) { for (const c of key) { hash ^= c.charCodeAt(0); } - return hash & MODULUS; + return hash % MODULUS; } /* 旋转哈希 */ diff --git a/codes/typescript/chapter_hashing/simple_hash.ts b/codes/typescript/chapter_hashing/simple_hash.ts index 9d2be67c1..54c1fa283 100644 --- a/codes/typescript/chapter_hashing/simple_hash.ts +++ b/codes/typescript/chapter_hashing/simple_hash.ts @@ -31,7 +31,7 @@ function xorHash(key: string): number { for (const c of key) { hash ^= c.charCodeAt(0); } - return hash & MODULUS; + return hash % MODULUS; } /* 旋转哈希 */