Week 3: Feb 9 - Feb 15, 2026
Unit II: JavaScript Introduction
Week Overview
This week introduces JavaScript — the programming language that makes web pages interactive. You will learn variables, data types, functions, event handling, and control flow.
Course Outcome: CO-2 (K3 - Application) Duration: 1 week (4 lectures + 1 lab)
Lab: CSS Styling & Responsive Design
Lecture 9: JavaScript Introduction & Variables
What is JavaScript?
- Programming language that runs in the browser
- Makes HTML pages interactive and dynamic
- Complements HTML (structure) and CSS (styling)
Declaring Variables
Data Types
Operators
Lecture 10: Functions in JavaScript & Returning Data
Function Declaration
Function Expression & Arrow Functions
Return Values
Default Parameters
Lecture 11: UI Events & Event Handling
Adding Event Listeners
Common Events
Event Object
Form Event Validation
Lecture 12: Conditions & Looping in JavaScript
if / else if / else
switch Statement
Loops
// for loop
for (let i = 0; i < 5; i++) { console.log(i); }
// while loop
let count = 0;
while (count < 5) { count++; }
// for...of (values in an iterable)
for (const item of ['a', 'b', 'c']) { console.log(item); }
// for...in (keys of an object)
for (const key in { x: 1, y: 2 }) { console.log(key); }Ternary Operator
Lab 3: CSS Design and JavaScript Validation
Objectives
- Apply CSS design to the HTML pages from Week 2
- Add basic JavaScript form validation
- Practice event listeners
Activities
- Style the registration form with CSS (box model, colours, fonts)
- Add a
submitevent listener that validates required fields - Highlight invalid fields with a red border using JavaScript
- Create a toggle button that shows/hides a section
- Practice using
console.logfor debugging
Deliverables
- HTML with external CSS and linked JavaScript file
- Working form validation
- GitHub commit with changes
Key Takeaways
✅ Use const by default; let when the value needs to change
✅ JavaScript functions encapsulate reusable logic and can return values
✅ Events link user actions (click, input, submit) to handler functions
✅ if/else, switch, for, and while control program flow
✅ Always use === (strict equality) — avoid ==
Next Week
We’ll advance your JavaScript knowledge: - Lecture 13: Block Scope Variables (let vs const deep dive) - Lecture 14: Objects & Object Literals - Lecture 15: DOM Manipulation & Array Methods - Lecture 16: Revision & Practical (JavaScript + DOM)