一页面试题
作者:admin 日期:2021-11-20
Javascript代码
- // 第1题
- let str = "2434cab"
- let arr = [...str]
- console.log(arr)
- let sss = []
- do {
- let rrr = _.takeRight(arr, 2)
- arr.length = arr.length - 2
- sss.push(rrr[0]+rrr[1])
- } while (arr.length>2);
- sss.push(_.replace(_.toString(arr),',',''))
- console.log("第1题答案:",sss)
- // 第2题
- let sss = []
- for (let i = 1; i < 101; i++) {
- let flag35 = (i % 3 == 0) && (i % 5 == 0)
- let flag3 = (i % 3 == 0)
- let flag5 = (i % 5 == 0)
- if(flag35){sss.push("bb35");continue;}
- if(flag3){sss.push("bb3");continue;}
- if(flag5){sss.push("bb5");continue;}
- sss.push(i)
- }
- console.log("第2题答案:",sss)
- //第3题
- let rect = document.getElementById('rect')
- console.log("第3题答案:", [rect.getBoundingClientRect().width,rect.getBoundingClientRect().height])