This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const instance = new Trip(["Boston", "Salem"], 600, 6); | |
| console.log(instance.durationInHours()) // => 144 hours | |
| console.log(instance.destination.durationInHours()) // TypeError: | |
| // instance.destination.durationInHours is not a function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Trip { | |
| constructor(destination, budget, passports) { | |
| this.destination = destination; | |
| (this.budget = budget), (this.duration = 6); | |
| } | |
| durationInHours() { | |
| return `${24 * this.duration} hours` | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let myTrip = { | |
| location: "Boston", | |
| budget: 600, | |
| passports: true | |
| } | |
| Object.defineProperty(myTrip, 'passports', {configurable: false} ) | |
| function deleteProperty(object, property) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const myTrip = { | |
| location: "Boston", | |
| budget: 600, | |
| duration: function(arg) { return arg } | |
| } | |
| function deleteProperty(object, property) { | |
| return delete object[property] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const hello = 'hello' | |
| goodbye = 'goodbye' | |
| console.log(delete hello) // false | |
| console.log(delete goodbye) // true | |
| console.log(hello, goodbye=undefined) // hello undefined |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const myTrip = { | |
| location: "Boston", | |
| budget: 600, | |
| duration: function(arg) { return arg } | |
| } | |
| function deleteProperty(object, property) { | |
| return delete object[property] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function locateGrade(objStudent, error) { | |
| let student = objStudent.student; | |
| if (!student) return error.error_message; | |
| const quiz_grades = | |
| student.quiz_grades !== undefined ? student.quiz_grades : [0, 0, 0]; | |
| const test_grades = | |
| objStudent.student.test_grades !== undefined ? student.test_grades : [0, 0]; | |
| const extra_credit = | |
| student.extraCredit !== undefined ? student.extra_credit : 0; | |
| return [...quiz_grades, ...test_grades, extra_credit]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const error = { | |
| error_message: "Student not found", | |
| }; | |
| const objStudent = { | |
| student: { | |
| name: "Anthony", | |
| quiz_grades: [10, 9, 7], | |
| test_grades: [7, 8], | |
| extra_credit: undefined, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let nestObject = { | |
| arrayOfObjects: [ | |
| { | |
| one: 1, | |
| two: 2, | |
| three: 3, | |
| }, | |
| { | |
| restOfNumbers: [{four: 4}, {five: 5}, 6, 7, 8, 9, 10], | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let numbers = { numbers: { one: 1 } }; | |
| const { | |
| numbers: { one }, | |
| } = numbers; | |
| console.log(one); // 1 | |
| const { | |
| numbers: { one: numberOne }, |