Why does "const testing;" error despite my variable being initialized by the value 'Enchiladas'?

Running this code gives me an error “Missing initializer in const declaration”

const entree = ‘Enchiladas’;
const testing;

Isn’t "Enchiladas’ the initializer?


You have two variables there. I looked at the lesson, and the error you are receiving is an expected part of the lesson to show what happens when you try to declare a variable with the const keyword without assigning an initial value.

Here, entree is successfully declared with const and an initial value:
const entree = 'Enchiladas';

Here, an error is thrown since no value is assigned to the const variable, testing:
const testing;

1 Like