From dc3ac1fae66a9aea15e1a10565f0e9b1d841c3a7 Mon Sep 17 00:00:00 2001 From: IsChristina <315644507@qq.com> Date: Mon, 12 Dec 2022 21:39:48 +0800 Subject: [PATCH] add ; --- docs/chapter_array_and_linkedlist/array.md | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/chapter_array_and_linkedlist/array.md b/docs/chapter_array_and_linkedlist/array.md index c6f2fec..917c75a 100644 --- a/docs/chapter_array_and_linkedlist/array.md +++ b/docs/chapter_array_and_linkedlist/array.md @@ -50,8 +50,8 @@ comments: true ```javascript title="array.js" /* 初始化数组 */ - var arr = new Array(5).fill(0) - var nums = [1, 3, 2, 5, 4] + var arr = new Array(5).fill(0); + var nums = [1, 3, 2, 5, 4]; ``` === "TypeScript" @@ -140,10 +140,10 @@ elementAddr = firtstElementAddr + elementLength * elementIndex /* 随机返回一个数组元素 */ function randomAccess(nums){ // 在区间 [0, nums.length) 中随机抽取一个数字 - const random_index = Math.floor(Math.random() * nums.length) + const random_index = Math.floor(Math.random() * nums.length); // 获取并返回随机元素 - random_num = nums[random_index] - return random_num + random_num = nums[random_index]; + return random_num; } ``` @@ -236,13 +236,13 @@ elementAddr = firtstElementAddr + elementLength * elementIndex /* 扩展数组长度 */ function extend(nums, enlarge){ // 初始化一个扩展长度后的数组 - let res = new Array(nums.length + enlarge).fill(0) + let res = new Array(nums.length + enlarge).fill(0); // 将原数组中的所有元素复制到新数组 for(let i=0; i