Donate
Back to Introduction to Web Development
Sign in to save your progress and earn a certificate.

Module 5: Introduction to JavaScript

Learning Objectives
  • Declare and use variables and basic data types
  • Write simple functions and conditional logic
  • Explain the role JavaScript plays alongside HTML and CSS

While HTML provides structure and CSS provides style, JavaScript provides behavior -- it's the only one of the three that can react to user actions, change content after the page loads, and perform calculations. Variables, declared with let or const (modern alternatives to the older var), store data such as numbers, strings of text, booleans that are true or false, and arrays, which are lists of values; functions are reusable blocks of code, written as function greet(name) { return "Hello " + name; }, that run when called. Conditional logic using if/else statements lets a program make decisions -- for example, checking whether a form field was left empty before allowing a submission -- and is one of the first concepts that makes code feel genuinely interactive rather than static.

Module Quiz

1. In modern JavaScript, which keywords are preferred over the older 'var' for declaring variables?

2. Which of the following best describes JavaScript's role in a web page?

3. An if/else statement is used to: