Js not for, forEach, map and other cycle to achieve multiplication table

var str='';
function mt(p,n){
if(p<10){
if (n<=p){
str += n+'*'+p+'='+p*n+'\t';
n++;
mt(p,n);
}
else{
n=1;
p++;
str += '\n';
mt(p,n)
}
}else{
console.log(str);
}
}
mt(1,1);

Guess you like

Origin www.cnblogs.com/jia-bk-home/p/11419225.html