From 8b2b75112cdabc5e59883ed3fcb9b908e2f74e7f Mon Sep 17 00:00:00 2001 From: Yudong Jin Date: Tue, 13 Dec 2022 00:10:29 +0800 Subject: [PATCH] Update array.js --- codes/javascript/chapter_array_and_linkedlist/array.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/codes/javascript/chapter_array_and_linkedlist/array.js b/codes/javascript/chapter_array_and_linkedlist/array.js index b496797be..754e8fb15 100644 --- a/codes/javascript/chapter_array_and_linkedlist/array.js +++ b/codes/javascript/chapter_array_and_linkedlist/array.js @@ -70,11 +70,11 @@ function find(nums, target) { /* 初始化数组 */ const arr = new Array(5).fill(0); console.log("数组 arr =", arr); -const nums = [1, 3, 2, 5, 4]; +let nums = [1, 3, 2, 5, 4]; console.log("数组 nums =", nums); /* 随机访问 */ -random_num = randomAccess(nums); +let random_num = randomAccess(nums); console.log("在 nums 中获取随机元素", random_num); /* 长度扩展 */ @@ -93,5 +93,5 @@ console.log("删除索引 2 处的元素,得到 nums =", nums); traverse(nums); /* 查找元素 */ -const index = find(nums, 3); +let index = find(nums, 3); console.log("在 nums 中查找元素 3 ,得到索引 =", index);