@seangarvey/

createPersonObject

JavaScript

create an object to represent a person/me. use both dot and bracket notation. create an if/else statement for alarm variable. console log...

fork
loading
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const person = {
  name: "Sean",
  age: 28,
  weekendAlarm: 'No alarms needed.',
  weekAlarm: 'Alarm set to 7AM.'
};
person.weekAlarm = 'Alarm set to 10AM.';

let day = 'Wednesday';
let alarm;
if (day === 'Saturday' || day === 'Sunday') {
  alarm = 'weekendAlarm';
} else {
  alarm = 'weekAlarm';
}
person.hobbies = ['Coding', 'Learning'];
person['hobbies'] = ['Coding'];

person.sayHello = () => {
  return 'Hello, there!';
};
console.log(person.sayHello());
console.log('My name is ' + person.name + '.');
console.log('I am ' + person.age + ' years old.');
console.log(person[alarm]);
console.log('My hobbies include ' + person.hobbies.join(' and ') + '.');
Native Browser JavaScript