Skip to content

Commit 35cf812

Browse files
committed
feat: 新增下划线转驼峰
1 parent 2e72b4c commit 35cf812

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
- [x] 发布订阅模式
66
- [x] 数组转树
77
- [x] 树转数组
8-
- [x] 生成 x\y 的数组 用 0 填充
8+
- [x] 生成 x\*y 的数组 用 0 填充
99
- [x] 扁平化数组
10+
- [x] 下划线转驼峰
1011

1112
## 排序算法
1213

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
let str = "create_array_to_save_every_day_price";
2+
3+
function changeStr(str) {
4+
const temp = [...str]
5+
for (let i = 0; i < temp.length; i++) {
6+
if (temp[i] === '_') {
7+
temp[i + 1] = temp[i + 1].toUpperCase()
8+
temp.splice(i, 1)
9+
i--
10+
}
11+
}
12+
return temp.join('')
13+
}
14+
15+
const res = changeStr(str)
16+
17+
console.log(res);

0 commit comments

Comments
 (0)