Why am I getting an error `ReferenceError: ____ is not defined`?


#1

Question

Why am I getting an error ReferenceError: ____ is not defined?

Answer

Make sure to include the quotation marks in your bracket notation! Proper syntax for bracket notation requires you to use quotation marks or single quotes around the key name inside of the brackets in order to access the key’s value. For example:

// If we have the following object:

				let dog = {
							name: ‘Max’,
	breed: ‘Chihuahua’
				};

		// These both work:
					console.log(dog[‘breed’]);
console.log(dog[“breed”]);

// This doesn’t:
				
console.log(dog[breed]);