Skip to content

Commit

Permalink
Test success
Browse files Browse the repository at this point in the history
  • Loading branch information
krahets authored Apr 22, 2024
1 parent f6da242 commit cbb1f72
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions codes/javascript/chapter_array_and_linkedlist/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

/* 随机访问元素 */
function andomAccess(nums) {
function randomAccess(nums) {
// 在区间 [0, nums.length) 中随机抽取一个数字
const random_index = Math.floor(Math.random() * nums.length);
// 获取并返回随机元素
Expand All @@ -16,7 +16,7 @@ function andomAccess(nums) {
/* 扩展数组长度 */
// 请注意,JavaScript 的 Array 是动态数组,可以直接扩展
// 为了方便学习,本函数将 Array 看作长度不可变的数组
functio extend(nums, enlarge) {
function extend(nums, enlarge) {
// 初始化一个扩展长度后的数组
const res = new Array(nums.length + enlarge).fill(0);
// 将原数组中的所有元素复制到新数组
Expand Down

0 comments on commit cbb1f72

Please sign in to comment.