BCA Student Stories & UpdatesLive
JavaScript Operators: Arithmetic, Strict Equality (===) & Logical Conditions
Operators allow you to perform calculations and make comparisons in code. In JavaScript, understanding type coercion and the distinction between loose equality (==) and strict equality (===) is fundamental to writing bug-free software.
Day 22 Step-by-Step Practical Flow
🎯1. What You Will Learn Today
JavaScript Operators: Arithmetic, Strict Equality (===) & Logical Conditions — Comprehensive Practical Guide
Har concept ko visual mental models, code anatomy aur practical industry tips ke sath samjhein.
Operators allow you to perform calculations and make comparisons in code. In JavaScript, understanding type coercion and the distinction between loose equality (==) and strict equality (===) is fundamental to writing bug-free software.
"Loose equality (==) is like an airport gate agent who lets a passenger through because their movie prop paper bill says 100. Strict equality (===) inspects both the printed value AND whether it is real government currency of the expected material."
👨🏫3. Teacher Demonstration Code
Notice how "100" == 100 is true, but "100" === 100 is false because string !== number.
<!DOCTYPE html>
<html>
<body>
<script>
const userAge = 19;
const hasCollegeID = true;
// Strict equality comparison
console.log("5 == '5' (Loose):", 5 == '5'); // true (Coerced)
console.log("5 === '5' (Strict):", 5 === '5'); // false (Different types)
// Logical condition
const isEligibleForExam = (userAge >= 18) && hasCollegeID;
console.log("Eligible for Exam:", isEligibleForExam);
</script>
</body>
</html>2. Hands-On Practical Lab: Follow Instructions in VS Code
Code like a professional software engineer! Follow the step-by-step instructions below in Visual Studio Code (VS Code) on your PC, test your output locally, and push to GitHub.
Day 22 Practical Task Test Studio
Compute percentage by dividing obtainedMarks by totalMarks, multiplying by 100, and storing in const percentage.
Declare const isPassed which evaluates to true if percentage >= 40, and log the result.
Spot the Bug: Accidental Single Equals Assignment in Condition
Tap or click on the exact line below that contains the error:
Click any code linelet marks = 35;if (marks = 100) { // Bug: Single equals assignment instead of comparison! console.log("Distinction Student!");}Senior Developer Forensic Analysis:
Single equals (=) is an assignment operator, not a comparison. (marks = 100) assigns 100 to marks, which evaluates to truthy (100 is truthy), always executing the if block regardless of actual marks.
📝Independent Practice: Assignment
📄 eligibility-calculator.htmlAdmission Eligibility Calculator Script
- •Create day-22/index.html with student test scores.
- •Implement arithmetic formulas for total, average, and percentage.
- •Write compound logical conditions: (mathScore >= 60 && physicsScore >= 55 && csScore >= 65).
- •Print formatted PASS/FAIL criteria to the browser console.
Open Visual Studio Code on your PC (code .), create eligibility-calculator.html, paste this complete step-by-step verified code, test in your browser, and push to your GitHub repo:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BCA Day 22 - Admission Eligibility Calculator</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: 'Segoe UI', Tahoma, sans-serif;
background: #0b1120;
color: white;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.calc-card {
background: #1e293b;
border: 1px solid #334155;
border-radius: 16px;
padding: 32px;
max-width: 480px;
width: 100%;
}
h1 { font-size: 20px; color: #38bdf8; margin-bottom: 16px; }
.result-box {
background: #0f172a;
padding: 16px;
border-radius: 10px;
font-family: monospace;
font-size: 13px;
color: #cbd5e1;
line-height: 1.8;
}
.status { font-weight: bold; font-size: 16px; margin-top: 12px; }
.pass { color: #10b981; }
.fail { color: #ef4444; }
</style>
</head>
<body>
<div class="calc-card">
<h1>BCA Admission Eligibility Check</h1>
<div class="result-box" id="resultBox">Computing eligibility...</div>
</div>
<script>
// Test Scores
const mathScore = 72;
const physicsScore = 65;
const csScore = 88;
// Arithmetic Formulas
const totalMarks = mathScore + physicsScore + csScore;
const maxMarks = 300;
const average = (totalMarks / 3).toFixed(2);
const percentage = ((totalMarks / maxMarks) * 100).toFixed(2);
// Compound Logical Condition
const isEligible = (mathScore >= 60 && physicsScore >= 55 && csScore >= 65);
const logOutput = `Mathematics: ${mathScore}/100
Physics: ${physicsScore}/100
Computer Science: ${csScore}/100
------------------------------
Total: ${totalMarks}/${maxMarks}
Average: ${average}
Percentage: ${percentage}%`;
console.log(logOutput);
console.log("Admission Status:", isEligible ? "ELIGIBLE FOR ADMISSION" : "NOT ELIGIBLE");
document.getElementById("resultBox").innerHTML = `
<div>${logOutput.replace(/\n/g, "<br>")}</div>
<div class="status ${isEligible ? 'pass' : 'fail'}">
Status: ${isEligible ? "✓ ELIGIBLE FOR BCA ADMISSION" : "✕ NOT ELIGIBLE"}
</div>
`;
</script>
</body>
</html>🎓4. Viva Check: Mandatory Conceptual Test
What is the evaluated output of the expression: typeof (5 + "5") in JavaScript?
5. Mandatory Step: Push to GitHub to Unlock Next Lesson
Target Repo: html-css-projects
Exact GitHub Setup Guide & Expected Structure
Day 22 RequirementsFollow these exact folder and file names to prevent verification errors.
index.html: Avoid spaces or custom names like Alan Turing..html or Index.HTML. Linux/GitHub servers are strictly case-sensitive.day-22/ for today so you don't overwrite previous days.main.You are welcome to read all notes, inspect code snippets, and practice all exercises of Day 22 freely! To officially submit your GitHub repository and unlock subsequent days in your portfolio, please complete Day 21: JavaScript Introduction: <script> Tag, Variables (let, const) & Data Types first.
Complete Day 21 First