<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>求输入的3个数的最大值</title></head><body><scripttype="text/javascript">let a =parseInt(prompt("请输入第一个数:"));let b =parseInt(prompt("请输入第二个数:"));let c =parseInt(prompt("请输入第三个数:"));(a>b?a:b)>c?alert(a>b?a:b):alert(c);</script></body></html>
输入圆的半径求面积和周长
<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>输入圆的半径求面积和周长</title></head><body><div>圆的半径: <inputid="r"type="text"></div><div>圆的周长: <inputid="cir"type="text"></div><div>圆的面积: <inputid="area"type="text"></div><scripttype="text/javascript">let r =prompt("请输入圆的半径");if(!isNaN(r)){let cir = Math.PI*r*2;let area = Math.PI*r*r;
document.getElementById('r').value= r;
document.getElementById('cir').value= cir.toFixed(2);
document.getElementById('area').value= area.toFixed(2);}else{alert("请输入正确的数字");}</script></body></html>
打印金字塔,空心金字塔,倒金字塔
<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>打印金字塔,空心金字塔,倒金字塔</title></head><body><script>let n =prompt("请输入金字塔层数:");
n =parseInt(n);
document.write("实心金字塔:<br/>");for(let i =1;i <= n; i++){for(let j =n-1;j>=i;j--){
document.write("   ");}for(let k=1;k<=i*2-1;k++){
document.write("*  ");}
document.write("<br/>");}
document.write("空心金字塔:<br/>");for(let i =1;i <= n; i++){for(let j =n-1;j>=i;j--){
document.write("    ");}for(let k=1;k<=i*2-1;k++){if(i==n){
document.write("*   ");}elseif(k==1||k==i*2-1){
document.write("*   ");}else{
document.write("    ");}}
document.write("<br/>");}
document.write("倒金字塔:<br/>");for(let i =1;i <= n; i++){for(let m=1;m<=i;m++){
document.write("  ");}for(let j =n-1;j<=i-1;j++){
document.write(" ");}for(let k=1;k<=2*(n-i+1)-1;k++){
document.write("* ");}
document.write("<br/>");}</script></body></html>
打印九九乘法表
<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>打印九九乘法表</title></head><body><scripttype="text/javascript">let i,j;for(i =1;i<=9;i++){for(j=1;j<=i;j++){let sum =0;
sum = j * i;
document.write(j,"*",i,"=",sum,' ')}
document.write("<br/>")}</script></body></html>
打印倒正金字塔直线
<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>打印倒正金字塔直线</title></head><body><scripttype="text/javascript">let n =prompt("请输入金字塔层数:");for(let i = n;i >-(n+1); i--){
document.write("<hr width="+10*Math.abs(i)+"%/>")if(i<=-n){break;}}</script></body></html>