mirror of
				https://github.com/krahets/hello-algo.git
				synced 2025-11-04 14:18:20 +08:00 
			
		
		
		
	Update array.js
This commit is contained in:
		@ -70,11 +70,11 @@ function find(nums, target) {
 | 
				
			|||||||
/* 初始化数组 */
 | 
					/* 初始化数组 */
 | 
				
			||||||
const arr = new Array(5).fill(0);
 | 
					const arr = new Array(5).fill(0);
 | 
				
			||||||
console.log("数组 arr =", arr);
 | 
					console.log("数组 arr =", arr);
 | 
				
			||||||
const nums = [1, 3, 2, 5, 4];
 | 
					let nums = [1, 3, 2, 5, 4];
 | 
				
			||||||
console.log("数组 nums =", nums);
 | 
					console.log("数组 nums =", nums);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* 随机访问 */
 | 
					/* 随机访问 */
 | 
				
			||||||
random_num = randomAccess(nums);
 | 
					let random_num = randomAccess(nums);
 | 
				
			||||||
console.log("在 nums 中获取随机元素", random_num);
 | 
					console.log("在 nums 中获取随机元素", random_num);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* 长度扩展 */
 | 
					/* 长度扩展 */
 | 
				
			||||||
@ -93,5 +93,5 @@ console.log("删除索引 2 处的元素,得到 nums =", nums);
 | 
				
			|||||||
traverse(nums);
 | 
					traverse(nums);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* 查找元素 */
 | 
					/* 查找元素 */
 | 
				
			||||||
const index = find(nums, 3);
 | 
					let index = find(nums, 3);
 | 
				
			||||||
console.log("在 nums 中查找元素 3 ,得到索引 =", index);
 | 
					console.log("在 nums 中查找元素 3 ,得到索引 =", index);
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user