By GokiSoft.com|
19:32 23/10/2023|
Học JS
Bài tập - Tìm số lớn nhất - Lập trình Javascript
Tìm số lớn nhất
Yêu cầu nhập vào 5 số thông quan prompt -> In ra màn hình số lớn nhất.
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)
![hohuy1610@gmail.com [community,C2108L]](https://www.gravatar.com/avatar/15e0636181e201af8d78b5d3e072fd0b.jpg?s=80&d=mm&r=g)
hohuy1610@gmail.com
2021-11-24 16:40:52
https://github.com/HoGiaHuy2003/C2108L-HTML-CSS-JS/tree/master/day-8/bt2006
#index.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 type="text/javascript">
var n1
n1 = prompt(`Enter N1`)
var n2
n2 = prompt(`Enter N2`)
var n3
n3 = prompt(`Enter N3`)
var n4
n4 = prompt(`Enter N4`)
var n5
n5 = prompt(`Enter N5`)
if (n1 > n2) {
if (n1 > n3){
if (n1 > n4){
if (n1 > n5){
document.write(`max = ` + n1)
}
else{
document.write(`max = ` + n5)
}
}
else{
if (n4 > n5){
document.write(`max = ` + n4)
}
else{
document.write(`max = ` + n5)
}
}
}
else{
if(n3 > n4){
if(n3 > n5){
document.write(`max = ` + n3)
}
else{
document.write(`max = ` + n5)
}
}
else{
if (n4 > n5){
document.write(`max = ` + n4)
}
else{
document.write(`max = ` + n5)
}
}
}
}
else {
if(n2 > n3){
if(n2 > n4){
if (n2 > n5){
document.write(`max = `+ n2)
}
else{
document.write(`max = `+ n5)
}
}
else{
if (n4 > n5){
document.write(`max = ` + n4)
}
else{
document.write(`max = ` + n5)
}
}
}
else{
if(n3 > n4){
if(n3 > n5){
document.write(`max = ` + n3)
}
else{
document.write(`max = ` + n5)
}
}
else{
if (n4 > n5){
document.write(`max = ` + n4)
}
else{
document.write(`max = ` + n5)
}
}
}
}
</script>
</body>
</html>
![Triệu Văn Lăng [T2008A]](https://www.gravatar.com/avatar/1348e3562c6492c26f796cb1f45982a1.jpg?s=80&d=mm&r=g)
Triệu Văn Lăng
2020-10-18 13:56:30
#maxnumber(2006).html
<!DOCTYPE html>
<html>
<head>
<title>Input MaxNumber</title>
</head>
<body>
<script type="text/javascript">
var a, b, c, d, e;
a=prompt("nhap so thu 1: ");
b=prompt("nhap so thu 2: ");
c=prompt("nhap so thu 3: ");
d=prompt("nhap so thu 4: ");
e=prompt("nhap so thu 5: ");
var maxNumbers=a;
if(maxNumbers<b) {
maxNumbers=b;
} else
if(maxNumbers<c) {
maxNumbers=c;
} else
if (maxNumbers<d) {
maxNumbers=d;
} else
if (maxNumbers<e) {
maxNumbers=e;
} else {
maxNumbers=maxNumbers
}
document.write("so lon nhat la "+maxNumbers);
</script>
</body>
</html>
![Do Trung Duc [T2008A]](https://www.gravatar.com/avatar/2973ac07124f066b4605c535e8d39a99.jpg?s=80&d=mm&r=g)
Do Trung Duc
2020-10-18 13:23:01
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript">
var n1,n2,n3,n4,n5,max;
n1=prompt("Nhap so n1");
n2=prompt("Nhap so n2");
n3=prompt("Nhap so n3");
n4=prompt("Nhap so n4");
n5=prompt("Nhap so n5");
max=n1
if(n1<=n2){
max = n2;
}
if(max<=n3){
max = n3;
}
if(max<=n4){
max = n4;
}
if(max<=n5){
max = n5;
}
document.write("So lon nhat la:" + max)
</script>
</body>
</html>
![Trần Thị Khánh Huyền [T2008A]](https://www.gravatar.com/avatar/554e115833778e4294a01aebe228f3d6.jpg?s=80&d=mm&r=g)
Trần Thị Khánh Huyền
2020-10-18 09:43:15
#max.html
<!DOCTYPE html>
<html>
<head>
<title>timMax</title>
<meta charset="utf-8">
</head>
<body>
<script type="text/javascript">
var a = prompt("Nhap a =");
var b = prompt("Nhap b =");
var c = prompt("Nhap c =");
var d = prompt("Nhap d =");
var e = prompt("Nhap e =");
document.write("Max la: "+Math.max(a,b,c,d,e));
</script>
</body>
</html>
![Trần Văn Lâm [T2008A]](https://www.gravatar.com/avatar/cfc15c8cb7781ad669b013e01f9f1a6b.jpg?s=80&d=mm&r=g)
Trần Văn Lâm
2020-10-18 01:45:32
#max.html
<!DOCTYPE html>
<html>
<head>
<title>Tim Max</title>
<meta charset="utf-8">
</head>
<body>
<script type="text/javascript">
var max = 0;
var a = prompt('nhap a')
var b = prompt('nhap b')
var c = prompt('nhap c')
var d = prompt('nhap d')
var e = prompt('nhap e')
document.write('Max la:' + Math.max(a, b, c, d, e))
</script>
</body>
</html>
![Đức Sơn [T2008A]](https://www.gravatar.com/avatar/d2b971b7bc54e4a9689c3e2240f27949.jpg?s=80&d=mm&r=g)
Đức Sơn
2020-10-17 08:40:19
#js4.html
<!DOCTYPE html>
<html>
<head>
<title>Js</title>
</head>
<body>
<script type="text/javascript">
var a = prompt("Nhap a")
var b = prompt("Nhap b")
var c = prompt("Nhap c")
var d = prompt("Nhap d")
var e = prompt("Nhap e")
document.write('Max :' +Math.max(a,b,c,d,e))
</script>
</body>
</html>
![nguyễn Sử [T2008A]](https://www.gravatar.com/avatar/47487be2776ac2ec915b0936ef7ab5ae.jpg?s=80&d=mm&r=g)
nguyễn Sử
2020-10-16 16:28:56
#tim so lơn nhat.html
<!DOCTYPE html>
<html>
<head>
<title>tim so lon nhat</title>
<meta charset="utf-8">
</head>
<body>
<script type="text/javascript">
var a = prompt('nhập a',)
var b = prompt('nhập b',)
var c = prompt('nhập c',)
var d = prompt('nhập d',)
var e = prompt('nhập e',)
document.write('max : '+Math.max(a, b, c, d, e));
</script>
</body>
</html>
![vuong huu phu [T2008A]](https://www.gravatar.com/avatar/307a5cf29780afab49706dc8b15b86c6.jpg?s=80&d=mm&r=g)
vuong huu phu
2020-10-16 15:34:20
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<meta charset="utf-8">
<script type="text/javascript">
var a = prompt("nhap so a");
var b = prompt("nhap so b");
var c = prompt("nhap so c");
var d = prompt("nhap so d");
var e = prompt("nhap so e");
var max = 0;
if (a>max) {
max=a;
if (b>max) {
max=b;
if (c>max) {
max=c;
if (d>max) {
max=d;
if (e>max) {
max=e;
document.write(max);
}}}}}
</script>
</body>
</html>
![Nguyễn Xuân Mai [T2008A]](https://www.gravatar.com/avatar/d3d863d6f47708501814fb41e9c38f31.jpg?s=80&d=mm&r=g)
Nguyễn Xuân Mai
2020-10-16 15:30:51
<!DOCTYPE html>
<html>
<head>
<title>findmax</title>
<meta charset="UTF-8">
</head>
<body>
<script type="text/javascript">
var arr1 = [];
for (var i = 0; i < 5; i++) {
arr1[i]=prompt("Nhap so: ")
}
arr1.sort(function(a, b) {
return a - b
})
document.type("So Lon Nhat: " + arr1[arr1.length - 1])
</script>
</body>
</html>
![hainguyen [T2008A]](https://www.gravatar.com/avatar/32855ce6db55d60134d830aee06b41e5.jpg?s=80&d=mm&r=g)
hainguyen
2020-10-16 13:57:27
#btN.html
<!DOCTYPE html>
<html>
<head>
<title>Bot</title>
</head>
<body>
<script type="text/javascript">
var a1 = prompt('Nhap a1',)
var a2 = prompt('Nhap a2',)
var a3 = prompt('Nhap a3',)
var a4 = prompt('Nhap a4',)
var a5 = prompt('Nhap a5',)
document.write('Max : ' + Math.max(a1, a2, a3, a4, a5));
</script>
</body>
</html>