← Back to Programming Fundamentals
05

Basic Data Types: Choosing the Right Kind of Value

Learn to distinguish numbers, text, booleans, `undefined`, and `null` so you can represent information more clearly and avoid common beginner mistakes.

📘 Theory

Why Data Types Matter from Day One

Programming is not only about storing data, but about storing it in a form the program can interpret correctly.

If a shop stores a price as a number, it can add and compare it properly. If it stores that same price as text, the behavior may become confusing.

Choosing the right type is a small technical decision, but it affects calculations, validation, conditions, and messages later on.

  • The type affects how the value can be used.
  • Not everything visible as text on screen should be stored as text.
  • A poor type choice can create bugs that feel strange at first.

The Five Basic Types You Need Right Now

At this stage, you do not need all of JavaScript. You need to recognize the types you will use most often.

1

Number

For quantities, ages, prices, counters, and scores.

2

String

For names, messages, labels, and text content.

3

Boolean

For yes-or-no decisions: true or false.

4

Undefined

For something that exists but has not been given a value yet.

5

Null

For an intentionally empty or absent value.

How They Look in Code and What They Mean

The goal is not to memorize a list, but to read what each value is trying to represent.

1

`age` stores a quantity. `name` stores text. `accessAllowed` stores a decision. `discount` exists but still has no content. `avatar` marks an intentionally missing value.

2

This is where you start thinking like a programmer: not only seeing values, but also seeing meaning and intention.

🧭 Key visuals

A visual map of basic data types

It helps distinguish what each type represents and when to use it in beginner programming problems.

A teaching diagram comparing number, string, boolean, undefined, and null with examples and typical uses.

🧪 Learn by doing

Example Guided Example: Variables in a Simple User Record Each variable represents a different kind of data inside a recognizable case.

🏁 Challenges

Challenge Challenge: Fix the Types in a User Profile Rewrite the variables so the chosen type matches what they really represent.

🧰 Resources

Test

Check your knowledge with a test about Programming Fundamentals.

Test for Programming Fundamentals

What is this?

I'm Cristian Eslava and I sometimes build websites so both you and I can learn and experiment. culTest

I made this in February 2026 to make learning easier for my students. The idea is to learn web development by practicing and to keep expanding the project with new topics, tests and challenges.

It draws inspiration from MDN, W3Schools, CodePen, Manz and many other web development references. I wanted to combine useful theory, runnable examples, challenges and the testing system I had already built for culTest. culTest

If you liked it, if you didn't, or if you want to get in touch, write to me at cristianeslava@gmail.com