08 2021 档案

摘要:统计某一字符或字符串在另一个字符串中出现的次数 function asdf(arr,d){ let count = 0; while(arr.match(d)){ arr = arr.replace(d,''); count++; } console.log(count); } let arr = 阅读全文
posted @ 2021-08-30 09:39 Mr、DIVE 阅读(428) 评论(0) 推荐(0)
摘要:// 写一个去除制表符和换行符的方法 // 写一个去除制表符和换行符的方法 function asdf(arr){ // \n换行符 \r回车符 \t制表符 \g全局匹配; arr = arr.replace(/\n|\r|\t|/g,''); console.log(arr); } let arr 阅读全文
posted @ 2021-08-27 09:23 Mr、DIVE 阅读(249) 评论(0) 推荐(0)
摘要:写一个把字符串大小写切换的方法 function asdf(arr){ //判断小写toUpperCase(),判断大写toLowerCase(); let asd = []; arr.split('').map(item =>{ if(item.charCodeAt() <= 90){ asd.p 阅读全文
posted @ 2021-08-26 09:31 Mr、DIVE 阅读(163) 评论(0) 推荐(0)
摘要:写一个方法把下划线命名转成大驼峰命名 function asdf(arr){ //判断下划线位置,下划线位置加一,调用js的大写方法toUpperCase(); let a = arr.indexOf('_'); let lit = arr.split(''); lit[a+1] = lit[a+1 阅读全文
posted @ 2021-08-24 09:34 Mr、DIVE 阅读(608) 评论(0) 推荐(0)
摘要:// 去除字符串中最后一个指定的字符 function asdf(arr,ddd){ //反转字符串,使用replace默认模式第一次替换匹配的字符,再进行反转~ arr = arr.split('').reverse().join('').replace(ddd,'').split('').rev 阅读全文
posted @ 2021-08-23 09:53 Mr、DIVE 阅读(912) 评论(0) 推荐(0)
摘要:写一个方法去掉字符串中的空格,要求传入不同的类型分别能去掉前、后、前后、中间的空格 var str = ' 1 2 3445 6 '; console.log(str.split(' ').join('')) 阅读全文
posted @ 2021-08-20 09:38 Mr、DIVE 阅读(191) 评论(0) 推荐(0)
摘要:### 这一题是起源题 描述: 1. 这是一道大题目,把考点拆成了4个小项;需要侯选人用递归算法实现(限制15行代码以内实现;限制时间10分钟内完成): a) 生成一个长度为5的空数组arr。 b) 生成一个(2-32)之间的随机整数rand。 c) 把随机数rand插入到数组arr内,如果数组ar 阅读全文
posted @ 2021-08-19 10:27 Mr、DIVE 阅读(153) 评论(0) 推荐(0)
摘要:参考思路:https://www.cnblogs.com/allen2333/p/10514262.html 阅读全文
posted @ 2021-08-05 16:41 Mr、DIVE 阅读(420) 评论(0) 推荐(0)