functionrnd(max, min =0){return Math.round(Math.random()*(max - min))+ min
}
console.log(rnd(40,30));
如何获取当前是星期几
/方法一/let now =newDate();let week = now.getDay();let tw=["周日","周一","周二","周三","周四","周五","周六"]
console.log(tw[week]);/方法二/functiongetWeek(){let now =newDate()return'星期'+'日一二三四五六'[now.getDay()]}
console.log(getWeek());
手写一个补0的方法,如repairZero(8) 变成 “08”
/方法一/functionrepairZero(num){
num = num.toString()return num[1]? num :('0'+ num)}
console.log(repairZero(8));
console.log(repairZero(13));/方法二/functionrepairZero(num){if(num<10){
num='0'+num
}return num
}
console.log(repairZero(8))
获取30~40之间的一个随机数function rnd(max, min = 0) { return Math.round(Math.random() * (max - min)) + min }如何获取当前是星期几/方法一/let now = new Date(); let week = now.getDay(); let tw=["周日","周一","周二","周三","周四","周五","周六"] con