Mamun Labs Learn
JourneyGlossary
esc
  • Try “map”, “flexbox” or “state”.
Log in
Start learning
Phase 2 · 12 / 12Reading error messages
Phase 2JavaScript core
12 topics · 4–6 wks
  1. 1Values and variables
  2. 2Strings and numbers
  3. 3Making decisions with if
  4. 4Loops
  5. 5Functions in, values out
  6. 6Arrays
  7. 7Objects
  8. 8Arrays and map
  9. 9filter and find
  10. 10reduceoptional
  11. 11Scope
  12. 12Reading error messages
JourneyPhase 2Reading error messages
01 / 09Overview

Reading error messages

You'll learn to read a JavaScript error message, find the line it points to, and ask AI for help with the right details.

Why it mattersErrors are not failures, they are directions. Developers who read them calmly fix bugs in minutes instead of hours.
about 60 min·needs: Functions in, values out, Arrays, Objects, Scope
02 / 09

Watch & read

Start with the required ones. The others are there when you need them.

Article
What went wrong? Troubleshooting JavaScriptMDN · Learn web development · 25 min · English
MMamun's noteRead "Types of error" and "Fixing errors reported in the console". It uses a small guessing game; you can read along without downloading it.
Docs
TypeError: "x" is (not) "y"MDN Web Docs · error reference · 5 min · English
MMamun's noteThe page for "Cannot read properties of undefined", the error you'll see most. Read the top part and the first example.
DocsOptional
ReferenceError: "x" is not definedMDN Web Docs · error reference · 5 min · English
MMamun's noteShort page on "is not defined". The examples on spelling and scope match what you learned in the scope topic.
VideoOptional
Best debugging tips for beginnersYouTube · Web Dev Simplified · 12 min · English
MMamun's noteShows how to find and fix syntax errors, then how to use console.log to hunt down a bug. Worth watching all of it once.
03 / 09

Explanation

Your code stops and the console turns red. It is tempting to panic or paste it straight into AI. Instead, read it. An error message tells you what went wrong and where.

Every message has the same shape:

Uncaught TypeError: Cannot read properties of undefined (reading 'name')
at nameAt (app.js:4:26)
at app.js:8:13

The first word is the type of error. Then comes the message in plain English. The lines that start with at are called the stack: the path the code took to get there. The first at line is where it broke: file app.js, line 4, character 26. The next line shows who called it.

Three types cover most beginner errors:

  • ReferenceError: x is not defined. You used a name that doesn't exist here. Check the spelling, and check scope.
  • TypeError: Cannot read properties of undefined (reading 'name'). You wrote something.name, but something was undefined. The problem is the thing before the dot. Often a find found nothing, or an index was past the end of an array.
  • SyntaxError. The code is not valid JavaScript, like a missing ) or }. Nothing runs at all. Look at the line it names, and also the line just before it.

People often read only the first few words and then guess. Read the whole first line, open the file at that line number, and ask: which value here is not what I expected?

When you ask AI, give it three things: the full error message, the few lines around the line number, and what you expected to happen. "Fix my code" gets a guess. Those three things get a real answer, and you learn why.

Words to recognise
errorReferenceErrorTypeErrorSyntaxErrorstackline numberconsoleundefined
04 / 09

Code tour

Click a line number with a ring to read the note for that line.

script.js5 notes
1const students = [{ name: "Rafi" }, { name: "Nusrat" }];
2
3function nameAt(index) {
return students[index].name;
Mentor note · line 4
The line that broke. students[index] is fine for 0 and 1, but students[2] is undefined.
5}
6
7console.log(nameAt(1));
console.log(nameAt(2));
9
10// Console:
11// Nusrat
// Uncaught TypeError: Cannot read properties of undefined (reading 'name')
// at nameAt (app.js:4:26)
// at app.js:8:13
05 / 09

Practice

Short drills. Take your time and read the code before you answer.

DrillPredict1 / 2
1const price = 100;
2console.log(prise * 2);
Predict the error
DrillRead the error, then fix it2 / 2
Run the code first and read the error. label should be the first letter of the last student's name, in capitals: "N". Fix it so both checks pass.
1
2
3
4
5
Try 1 of 3 · solution unlocks after 3
06 / 09

Quick check

3 questions. Each one explains itself after you answer.

  1. 1 / 3You see ReferenceError: totl is not defined. What is the most likely cause?
  2. 2 / 3user.name gives Cannot read properties of undefined (reading 'name'). What was undefined?
  3. 3 / 3In at checkout (cart.js:12:9), where do you look first?
07 / 09

Explain it back

Only you can see this. Log in to keep it.0 words
08 / 09

How confident are you with Reading error messages?

09 / 09

Done

You can now
Read an error in the console, name its type, and go straight to the line that caused it.
Next: Arrow functions Back to Phase 2
On this page
  1. 01Reading error messages
  2. 02Watch & read
  3. 03Explanation
  4. 04Code tour
  5. 05Practice
  6. 06Quick check
  7. 07Explain it back
  8. 08Confidence
  9. 09Done
Up next · 02 / 09Watch & read
Mamun Labs LearnFound a mistake on this page? Tell Mamun.
Mamun Labs Learn
JourneyGlossary
esc
  • Try “map”, “flexbox” or “state”.
Log in
Start learning
Log in to save your progress. Everything here works without an account.Log in to save progressLog in
Phase 2JavaScript core
12 topics · 4–6 wks
  1. 1Values and variables
  2. 2Strings and numbers
  3. 3Making decisions with if
  4. 4Loops
  5. 5Functions in, values out
  6. 6Arrays
  7. 7Objects
  8. 8Arrays and map
  9. 9filter and find
  10. 10reduceoptional
  11. 11Scope
  12. 12Reading error messages
JourneyPhase 2Reading error messages
01 / 09Overview

Reading error messages

You'll learn to read a JavaScript error message, find the line it points to, and ask AI for help with the right details.

Why it mattersErrors are not failures, they are directions. Developers who read them calmly fix bugs in minutes instead of hours.
about 60 min·needs: Functions in, values out, Arrays, Objects, Scope
02 / 09

Watch & read

Start with the required ones. The others are there when you need them.

Article
What went wrong? Troubleshooting JavaScriptMDN · Learn web development · 25 min · English
MMamun's noteRead "Types of error" and "Fixing errors reported in the console". It uses a small guessing game; you can read along without downloading it.
Docs
TypeError: "x" is (not) "y"MDN Web Docs · error reference · 5 min · English
MMamun's noteThe page for "Cannot read properties of undefined", the error you'll see most. Read the top part and the first example.
DocsOptional
ReferenceError: "x" is not definedMDN Web Docs · error reference · 5 min · English
MMamun's noteShort page on "is not defined". The examples on spelling and scope match what you learned in the scope topic.
VideoOptional
Best debugging tips for beginnersYouTube · Web Dev Simplified · 12 min · English
MMamun's noteShows how to find and fix syntax errors, then how to use console.log to hunt down a bug. Worth watching all of it once.
03 / 09

Explanation

Your code stops and the console turns red. It is tempting to panic or paste it straight into AI. Instead, read it. An error message tells you what went wrong and where.

Every message has the same shape:

Uncaught TypeError: Cannot read properties of undefined (reading 'name')
at nameAt (app.js:4:26)
at app.js:8:13

The first word is the type of error. Then comes the message in plain English. The lines that start with at are called the stack: the path the code took to get there. The first at line is where it broke: file app.js, line 4, character 26. The next line shows who called it.

Three types cover most beginner errors:

  • ReferenceError: x is not defined. You used a name that doesn't exist here. Check the spelling, and check scope.
  • TypeError: Cannot read properties of undefined (reading 'name'). You wrote something.name, but something was undefined. The problem is the thing before the dot. Often a find found nothing, or an index was past the end of an array.
  • SyntaxError. The code is not valid JavaScript, like a missing ) or }. Nothing runs at all. Look at the line it names, and also the line just before it.

People often read only the first few words and then guess. Read the whole first line, open the file at that line number, and ask: which value here is not what I expected?

When you ask AI, give it three things: the full error message, the few lines around the line number, and what you expected to happen. "Fix my code" gets a guess. Those three things get a real answer, and you learn why.

Words to recognise
errorReferenceErrorTypeErrorSyntaxErrorstackline numberconsoleundefined
04 / 09

Code tour

Click a line number with a ring to read the note for that line.

script.js5 notes
1const students = [{ name: "Rafi" }, { name: "Nusrat" }];
2
3function nameAt(index) {
return students[index].name;
Mentor note · line 4
The line that broke. students[index] is fine for 0 and 1, but students[2] is undefined.
5}
6
7console.log(nameAt(1));
console.log(nameAt(2));
9
10// Console:
11// Nusrat
// Uncaught TypeError: Cannot read properties of undefined (reading 'name')
// at nameAt (app.js:4:26)
// at app.js:8:13
05 / 09

Practice

Short drills. Take your time and read the code before you answer.

DrillPredict1 / 2
1const price = 100;
2console.log(prise * 2);
Predict the error
DrillRead the error, then fix it2 / 2
Run the code first and read the error. label should be the first letter of the last student's name, in capitals: "N". Fix it so both checks pass.
1
2
3
4
5
Try 1 of 3 · solution unlocks after 3
06 / 09

Quick check

3 questions. Each one explains itself after you answer.

  1. 1 / 3You see ReferenceError: totl is not defined. What is the most likely cause?
  2. 2 / 3user.name gives Cannot read properties of undefined (reading 'name'). What was undefined?
  3. 3 / 3In at checkout (cart.js:12:9), where do you look first?
07 / 09

Explain it back

Only you can see this. Log in to keep it.0 words
08 / 09

How confident are you with Reading error messages?

09 / 09

Done

You can now
Read an error in the console, name its type, and go straight to the line that caused it.
Next: Arrow functions Back to Phase 2
On this page
  1. 01Reading error messages
  2. 02Watch & read
  3. 03Explanation
  4. 04Code tour
  5. 05Practice
  6. 06Quick check
  7. 07Explain it back
  8. 08Confidence
  9. 09Done
Up next · 02 / 09Watch & read

Your code stops and the console turns red. It is tempting to panic or paste it straight into AI. Instead, read it. An error message tells you what went wrong and where.

Every message has the same shape:

Uncaught TypeError: Cannot read properties of undefined (reading 'name')
at nameAt (app.js:4:26)
at app.js:8:13

The first word is the type of error. Then comes the message in plain English. The lines that start with at are called the stack: the path the code took to get there. The first at line is where it broke: file app.js, line 4, character 26. The next line shows who called it.

Three types cover most beginner errors:

  • ReferenceError: x is not defined. You used a name that doesn't exist here. Check the spelling, and check scope.
  • TypeError: Cannot read properties of undefined (reading 'name'). You wrote something.name, but something was undefined. The problem is the thing before the dot. Often a find found nothing, or an index was past the end of an array.
  • SyntaxError. The code is not valid JavaScript, like a missing ) or }. Nothing runs at all. Look at the line it names, and also the line just before it.

People often read only the first few words and then guess. Read the whole first line, open the file at that line number, and ask: which value here is not what I expected?

When you ask AI, give it three things: the full error message, the few lines around the line number, and what you expected to happen. "Fix my code" gets a guess. Those three things get a real answer, and you learn why.

Words to recognise
errorReferenceErrorTypeErrorSyntaxErrorstackline numberconsoleundefined

Your code stops and the console turns red. It is tempting to panic or paste it straight into AI. Instead, read it. An error message tells you what went wrong and where.

Every message has the same shape:

Uncaught TypeError: Cannot read properties of undefined (reading 'name')
at nameAt (app.js:4:26)
at app.js:8:13

The first word is the type of error. Then comes the message in plain English. The lines that start with at are called the stack: the path the code took to get there. The first at line is where it broke: file app.js, line 4, character 26. The next line shows who called it.

Three types cover most beginner errors:

  • ReferenceError: x is not defined. You used a name that doesn't exist here. Check the spelling, and check scope.
  • TypeError: Cannot read properties of undefined (reading 'name'). You wrote something.name, but something was undefined. The problem is the thing before the dot. Often a find found nothing, or an index was past the end of an array.
  • SyntaxError. The code is not valid JavaScript, like a missing ) or }. Nothing runs at all. Look at the line it names, and also the line just before it.

People often read only the first few words and then guess. Read the whole first line, open the file at that line number, and ask: which value here is not what I expected?

When you ask AI, give it three things: the full error message, the few lines around the line number, and what you expected to happen. "Fix my code" gets a guess. Those three things get a real answer, and you learn why.

Words to recognise
errorReferenceErrorTypeErrorSyntaxErrorstackline numberconsoleundefined