From f661a3455db585dfeceb3a9806b1d4fcf8af6f9e Mon Sep 17 00:00:00 2001 From: JoseHung <1309716944@qq.com> Date: Fri, 23 Dec 2022 00:52:41 +0800 Subject: [PATCH] fix the annotation --- codes/javascript/chapter_searching/binary_search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codes/javascript/chapter_searching/binary_search.js b/codes/javascript/chapter_searching/binary_search.js index 1c4ed2a12..2272f823e 100644 --- a/codes/javascript/chapter_searching/binary_search.js +++ b/codes/javascript/chapter_searching/binary_search.js @@ -31,7 +31,7 @@ function binarySearch1(nums, target) { let m = parseInt((i + j) / 2); // 计算中点索引 m ,在 JS 中需使用 parseInt 函数取整 if (nums[m] < target) // 此情况说明 target 在区间 [m+1, j) 中 i = m + 1; - else if (nums[m] > target) // 此情况说明 target 在区间 [i, m-1] 中 + else if (nums[m] > target) // 此情况说明 target 在区间 [i, m] 中 j = m; else // 找到目标元素,返回其索引 return m;