Module 17: JavaScript Basics

Lesson 4 of 5 · 15–25 minutes

Data types

🏠The everyday picture

A form asks for your name (words), your age (a number) and "Do you agree? Yes/No" (a choice of two). Each kind of answer is handled differently: you can add ages, but not names.

📘What it really is

const learner = { name: "Asha", city: "Patna", level: 2 };
console.log(learner.city);

🖱️Try it

In the console, make an object describing yourself (name, city, modules done, and whether you've built a site: true or false). Print a sentence about yourself using a template string. Then try typeof on each value.

✅Quick check

What's days[1] if days is ["Mon", "Tue", "Wed"]?

Show the answer

"Tue", because arrays count from 0.

A form's age field gives "25". What type is it?

Show the answer

A string. It must be converted to a number before doing arithmetic.

← PreviousVariables
ProLearners Assist