JavaScript Fundamentals -- Objects in JavaScript

Exercise 1 Review


Here's one possible solution to the exercise:

'use strict';

// 1. Create a new object called person, with a firstName key and a lastName key
// Put your first and last name as values to those keys
const person = {
  firstName: 'Preston',
  lastName: 'Lamb'

// 2. Log the firstName key using dot notation
// 3. Log the lastName key using bracket notation
// 4. Freeze the object you created above

// 5. Try and change an attribute on the object. If you don't see the expected behavior, make the necessary fix so that the freeze method works.
person.middleInitial = 'J';

You can review the answers to this exercise here on StackBlitz.

Click here to read more about objects in JavaScript.