1. Conditional Branching in JavaScript
Control flow statements allow your code to make logical decisions based on Boolean expressions.
⊞HTML5 Web Code (index.html)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JS Control Flow</title>
</head>
<body style="background:#17181c; color:#fff; font-family:Arial; padding:30px;">
<h2>JavaScript Loops & Decisions</h2>
<ul id="number-list" style="list-style:none; padding:0;"></ul>
<script>
const marks = 85;
let grade = "";
if (marks >= 90) {
grade = "A+ (Outstanding)";
} else if (marks >= 75) {
grade = "A (Excellent)";
} else {
grade = "B (Good)";
}
const listElement = document.getElementById("number-list");
// Standard for loop
for (let i = 1; i <= 5; i++) {
const li = document.createElement("li");
li.style.padding = "6px 12px";
li.style.margin = "4px 0";
li.style.backgroundColor = "#1f2029";
li.style.borderLeft = "3px solid #04AA6D";
li.textContent = "Step #" + i + " - Grade: " + grade;
listElement.appendChild(li);
}
</script>
</body>
</html>
