10 - How to fix "Uncaught ReferenceError: Cannot access x before initialization" in JavaScript

The important bits

Exercise - Now you try it

// Fix the error name const name = "gaston";

Transcript

0:01 ReferenceError: Cannot access color before initialisation

0:06 what this means is two things: One we were using the const keyword to define a variable. In this case the variable color, and we are assigning it a value of red, and... Two: We are trying to access this variable before it was defined, so the solution here is that we have to move...

0:29 The color variable until after the definition

0:35 and there you go. It works.

END