1)JS找字符串中出现最多的字符
思路:var nnn="dsadajkwehwjkebkaneawhekqhwkejqlwenjl"
第一一个数组['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
双重遍历,进行替换,全都替换成“ ”,哪个能使nnn长度减少的多,哪个就是出现最多的数组
2)JS实现九九乘法表
var sum=0;
var wite;
for (var i = 1; i < 10; i++){
var div=$('<div class="class'+i+'"></div>');
$("body").append(div);
for(var j = i; j > 0; j--){
sum = j * i;
wite = (j+"X"+i+"="+sum);
div.prepend($('<span style="padding-right:10px">'+wite+'</span>'));
}}
3)JS重复输出一个给定的字符串
function repeatStringNumTimes(str, num) {let saveTex = strfor(let i=0;i<(num-1);i++){str =str+saveTex;}return str;}repeatStringNumTimes("abc", 3);
4)快速的让一个数组乱序
var arr = ['a',2,3,4,5,6,7,8,9,10];arr.sort(function(){return Math.random() - 0.5;})console.log(arr);
5)最快捷求最大值
var arr = [ 1,5,1,7,5,9];Math.max(...arr) // 9
6)更短的数组去重写法
[...new Set([2,"12",2,12,1,2,1,6,12,13,6])]
// [2, "12", 12, 1, 6, 13]