← Back to Course

📝 Variables, Values, and Data Types

Variables let programs remember information. Data types describe what kind of information is being stored, such as text, numbers, or true/false values.

Why This Matters

Nearly every program depends on storing data, updating it, and passing it around. Understanding the difference between a variable, a value, and a type is one of the first core programming skills.

Example: Basic Variables

const username: string = "Ruben";
let score: number = 0;
let isLoggedIn: boolean = true;

score = score + 10;

console.log(username);
console.log(score);
console.log(isLoggedIn);

Common Data Types

  • string for text
  • number for numeric values
  • boolean for true or false
  • array for lists of values
  • object for grouped related data

🎯 Key Ideas

  • Use const when a variable should not be reassigned
  • Use let when a value needs to change over time
  • Pick names that describe what the value represents
  • Choosing the right type makes code easier to reason about

Real Example

Example: Simple Profile Data

const studentName = "Mia";
const age = 16;
const isEnrolled = true;

console.log(`${studentName} is ${age} years old.`);
console.log(`Enrolled: ${isEnrolled}`);
← Back to Code Foundations