Skip to content

Commit 4cfd516

Browse files
committed
chore: update
1 parent c9ea4b0 commit 4cfd516

File tree

18 files changed

+62
-96
lines changed

18 files changed

+62
-96
lines changed

code/algorithm/front-end-ts/add.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

code/algorithm/front-end-ts/count.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
22
* 计数
3-
* @param str
43
*/
54
function count(str: string) {
65
// 转换为数组后去重
@@ -22,3 +21,5 @@ function count(str: string) {
2221
}
2322
return result
2423
}
24+
25+
count('12321')

code/algorithm/front-end-ts/duplicates.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* 找出数组 arr 中重复出现过的元素
33
*/
44
function duplicates(arr: number[]) {
5-
const sortArr = arr.sort()
6-
const result = []
5+
const sortArr: number[] = arr.sort()
6+
const result: number[] = []
77
const len = sortArr.length
88
for (let index = 0; index < len - 1; index++) {
99
if (sortArr[index] === sortArr[index++]) {

code/algorithm/front-end-ts/isUSD.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
22
* 检测是否为USD字符
3-
* @param str
43
*/
54
function isUSD(str: string) {
65
if (!str.startsWith('$')) {
@@ -33,4 +32,4 @@ function isUSD(str: string) {
3332
return true
3433
}
3534

36-
console.log(isUSD('$20,933,209.93'))
35+
isUSD('$20,933,209.93')

code/algorithm/front-end-ts/removeWithoutCopy.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
* - 直接在给定的 arr 数组上进行操作,并将结果返回
44
*/
55
function removeWithoutCopy(arr: number[], item: number) {
6+
// 第一种方法: filter过滤
67
// const result= arr.filter(value=>value!==item)
7-
// // 输出
8+
// 输出
89
// return result;
9-
// 每次都和arr中的首个元素去比较
10+
11+
// 第二种方法:循环遍历,每次都和arr中的首个元素去比较
1012
const len = arr.length
1113
for (let index = 0; index < len; index++) {
1214
if (arr[0] !== item) {
@@ -19,5 +21,4 @@ function removeWithoutCopy(arr: number[], item: number) {
1921
return arr
2022
}
2123

22-
const test = [1, 2, 2, 3, 4, 2, 2]
23-
console.log(removeWithoutCopy(test, 2))
24+
removeWithoutCopy([1, 2, 2, 3, 4, 2, 2], 2)

code/algorithm/front-end/add.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ function add(...inputs) {
2121
return _add
2222
}
2323

24-
const str = add(1, 6)(2)(3)
25-
console.log(str)
26-
console.log(add(1)(2)(3))
27-
console.log(add(1)(2, 3, 4))
24+
add(1, 6)(2)(3)
25+
add(1)(2)(3)
26+
add(1)(2, 3, 4)

code/algorithm/front-end/count.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
22
* 计数
3-
* @param str
43
*/
54
function count(str) {
65
// 转换为数组后去重
@@ -24,5 +23,4 @@ function count(str) {
2423
}
2524

2625
// 调用
27-
const result = count('abTT')
28-
console.log(result)
26+
count('abTT')

code/algorithm/front-end/duplicates.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ function duplicates(arr) {
1414
return [...new Set(result)]
1515
}
1616

17-
console.log(duplicates([1, 2, 4, 4, 3, 3, 1, 5, 3]))
17+
duplicates([1, 2, 4, 4, 3, 3, 1, 5, 3])

code/algorithm/front-end/isUSD.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ function isUSD(str) {
3333
return true
3434
}
3535

36-
console.log(isUSD('$20,933,209.93'))
36+
isUSD('$20,933,209.93')

code/algorithm/front-end/removeWithoutCopy.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@ function removeWithoutCopy(arr, item) {
1919
return arr
2020
}
2121

22-
const test = [1, 2, 2, 3, 4, 2, 2]
23-
console.log(removeWithoutCopy(test, 2))
22+
removeWithoutCopy([1, 2, 2, 3, 4, 2, 2], 2)

0 commit comments

Comments
 (0)