1.九九乘法表
html文件:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="./练习.js"></script>
</body>
</html>
js文件:
let i,j
for(i=1;i<=9;i++){
for(j=1;j<=i;j++){
document.write(`${j}*${i}=${i*j}  `)
}
document.write(`<br/>`)
}
2.在数组中遍历求最大值
html文件:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="./练习.js"></script>
</body>
</html>
js文件:
let arr=['2','1','33','22','56','43','44']
let i,j,max
j=arr.length
for(i=0;i<j;i++){
if(arr[i]>=arr[i+1]){
max=arr[i]
}
}
document.write(`最大数是:${max}`)