finished day 1 refresher

pull/73/head
Derrek Gass 5 years ago
parent 5048cc49a2
commit 44ab014c63

@ -1,5 +1,5 @@
class Person {
constructor(firstName='Ivy', lastName='Graham', age=30, country='USA', city='Santa Cruz') {
constructor(firstName='Ivy', lastName='Graham', age=30, country='USA', city='Santa Cruz', gender='Female') {
console.log(this) // should be empty upon instantiation
this.firstName = firstName
this.lastName = lastName
@ -8,6 +8,7 @@ class Person {
this.city = city
this.score = 0
this.skills = []
this.gender = gender
}
// class methods
getFullName() {
@ -32,9 +33,10 @@ class Person {
this.skills.length > 0 &&
this.skills.slice(0, this.skills.length - 1).join(', ') +
` and ${this.skills[this.skills.length - 1]}`
let formattedSkills = skills ? `They know ${skills}` : ''
let info = `${fullName} is ${this.age}. They live in ${this.city}, ${this.country}. ${formattedSkills}`
let pronoun = this.gender =='Male'? 'He' : 'She'
let formattedSkills = skills ? `${pronoun} knows ${skills}` : ''
let info = `${fullName} is ${this.age}. ${pronoun} lives in ${this.city}, ${this.country}. ${formattedSkills}`
return info
}
static favoriteSkill() {
@ -89,7 +91,7 @@ person1.setSkill = 'Traditional Chinese Medicine'
console.log(person1.getSkills)
console.log(person1.getPersonInfo())
const person2 = new Person('Derrek', 'Gass', 32, 'USA', 'Santa Cruz')
const person2 = new Person('Derrek', 'Gass', 32, 'USA', 'Santa Cruz', 'Male')
console.log(person2)
person2.setScore = 1
person2.setSkill = 'JavaScript'
@ -104,7 +106,7 @@ console.log(person2.getPersonInfo())
console.log(Person.favoriteSkill())
console.log(Person.showDateTime())
const student1 = new Student('Tobias', 'the Cat', 10, 'USA', 'Santa Cruz')
const student1 = new Student('Tobias', 'the Cat', 10, 'USA', 'Santa Cruz', 'Male')
student1.setSkill = 'Meowing'
student1.setSkill = 'Purring'
console.log(student1.saySomething())

@ -213,4 +213,5 @@ const personDest = {
}
// testing to see if we can drill down to user's first name
console.log(personDest.user.firstName)
console.log(personDest)
console.log(personDest)

Loading…
Cancel
Save