mh108
2/24/2020 - 7:54 PM

Object Basics

// jshint esversion: 6

let user1 = {
  // an object
  name: "John",
  age: 30,
  "UO ID": 951007243,
  friends: ["Joan", "Jack"],
  isAdmin: false
};

let user2 = {
  // an object
  name: "Joan",
  age: 22,
  "UO ID": 951001100,
  friends: ["John", "Jill"],
  isAdmin: true
};

let user3 = {
  // an object
  name: "Jill",
  age: 22,
  "UO ID": 951011101,
  friends: ["John", "Jack"],
  isAdmin: false
};

//javascript database: array of objects
let users = [user1, user2, user3];

//Does John know someone who knows someone who knows Jack, too?
if (
  users[0].friends[0] == users[1].name &&
  users[1]["friends"][1] == users[2].name &&
  users[2].friends[1] == users[0].friends[1]
) {
  console.log("true");
} else {
  console.log("false");
}