-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
42 lines (29 loc) · 913 Bytes
/
index.html
File metadata and controls
42 lines (29 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JS Task 1</title>
</head>
<body>
<script>
function gradeMessages() {
const grades = prompt("Enter the grades separated by commas (e.g., A,B,C):").split(",");
const messages = grades.map((grade) => {
const lowerGrade = grade.trim().toLowerCase();
if (lowerGrade === "a" || lowerGrade === "b" || lowerGrade === "c") {
return `${grade.trim()} is a pass`;
} else if (!grades.length || grades.some(grade => grade.trim() === "")) {
alert("Please enter valid grade!");
return;
} else {
return `${grade.trim()} is a fail`;
}
});
messages.forEach((message) => alert(message));
}
// Example usage
gradeMessages();
</script>
</body>
</html>