Variables and constants in JavaScript: name, read, and update
Learn to declare with let and const, read values, update variables, choose clear names, and understand block scope. Build and check a simple store record.
- Level
- Beginner
- Lessons
- 5
- Learning steps
- 75
Your lesson journey
Each lesson has a purpose. Follow the order or revisit an idea you want to practise.
5 of 5 lessons shown
The numbers show the lesson order, not your progress.
What you will learn
Declare and initialize variables and constants with let and const. Distinguish declaration, initialization, assignment, reassignment, and reading. Predict and check values displayed through console.log. Choose let or const according to reassignment needs during intended behavior. Use valid identifiers, descriptive names, and camelCase consistently. Explain introductory block scope and distinguish inner and outer declarations. Recognize basic causes of SyntaxError, ReferenceError, and TypeError in examples. Build and modify a store record, justifying declarations and checking outputs.
Before you start
Have completed courses 01 through 04 of Programming Fundamentals or know their content: JavaScript execution and console.log, introductory computer operation, problem analysis, algorithms, pseudocode, and desk checks. No experience declaring variables in real code is required. Exercises use fictional data and independent execution contexts without installing tools.
About this course
Read the full description
Course 05 of Programming Fundamentals from Código con Criterio. Connect names and assignments used in pseudocode with real JavaScript declarations. In five lessons you will progress from one variable to a store record with constants, changeable values, and initial and updated outputs.
Codi accompanies explanations, conceptual diagrams, executable examples, activities with hints and feedback, and free-practice labs. Incorrect snippets are identified as analysis examples and distinguished from valid starter programs.
The progression covers declaration, initialization, assignment, reading, reassignment, names, block scope, and basic errors. const is presented as protection against reassigning the identifier, without promising general value immutability. var appears only as historical reference.
The final challenge includes a working start, complete reference, value tracing, and an erroneous alternative. Activities assess understanding; free-form code and personal explanations are compared with expected results and receive no automatic correction.
You can use the browser console or labs without installations. Each example is independent; we explain how to distinguish redeclaration in a retained context from updating the program. Custom functions, conditions, loops, arrays, and objects are not introduced.
This course is part of these learning paths
Follow the suggested order or take this course on its own.