By GokiSoft.com|
20:14 15/02/2022|
Học JS
[Video] Bài tập - Tìm số lớn nhất - Lập trình Javascript - C2110L
Bài tập - Tìm số lớn nhất - Lập trình Javascript
#index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Tim Max (Javascript)</title>
</head>
<body>
<h1 style="text-align: center;">Tim Max</h1>
<script type="text/javascript">
var a1, a2, a3, a4, a5, max
// Nhap 5 so nguyen
a1 = parseFloat(prompt('Nhap a1', 0))
document.write(`a1 = ${a1}<br/>`)
a2 = parseFloat(prompt('Nhap a2', 0))
document.write(`a1 = ${a2}<br/>`)
a3 = parseFloat(prompt('Nhap a3', 0))
document.write(`a1 = ${a3}<br/>`)
a4 = parseFloat(prompt('Nhap a4', 0))
document.write(`a1 = ${a4}<br/>`)
a5 = parseFloat(prompt('Nhap a5', 0))
document.write(`a1 = ${a5}<br/>`)
max = a1
if(max < a2) {
max = a2
}
if(max < a3) {
max = a3
}
if(max < a4) {
max = a4
}
if(max < a5) {
max = a5
}
document.write(`Max: ${max}`)
</script>
</body>
</html>
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)