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 Arithmetic { | |
| // inititalize the private property | |
| #value; | |
| // add getter for value | |
| get val() { | |
| return this.#value; // <== access the private property | |
| } | |
| // rest of the code truncated for clarity |
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 Arithmetic { | |
| // add getter for value | |
| get val() { | |
| return this.value; | |
| } | |
| // rest of the code truncated for clarity | |
| } | |
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 Arithmetic { | |
| constructor() { | |
| this.value = 0; | |
| } | |
| sum(...args) { | |
| this.value = args.reduce((sum, current) => sum + current, 0); | |
| return this; | |
| } | |
| add(value) { | |
| this.value = this.value + value; |
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 Arithmetic { | |
| constructor() { | |
| this.value = 0; | |
| } | |
| get val() { | |
| return this.value; | |
| } | |
| sum(...args) { | |
| this.value = args.reduce((sum, current) => sum + current, 0); | |
| return this; |
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 ChainAble { | |
| firstMethod() { | |
| console.log('This is the First Method'); | |
| return this; | |
| } | |
| secondMethod() { | |
| console.log('This is the Second Method'); | |
| return this; | |
| } |
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
| { | |
| address: 'plot 1', | |
| owner: 'segun', | |
| type: 'duplex', | |
| color: 'green', | |
| rooms: '5', | |
| kitchens: '1', | |
| windows: 20 | |
| } |
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
| { | |
| address: 'plot 1', | |
| owner: 'segun', | |
| type: 'duplex', | |
| color: 'green', | |
| rooms: '5', | |
| kitchens: '1', | |
| windows: 21 | |
| } |
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
| { | |
| windows: 21 | |
| } |
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 ShapeShifter { | |
| constructor(arg) { | |
| this.message = ''; | |
| const argType = typeof arg; | |
| const argTypeToTitleCase = `${argType[0].toUpperCase()}${argType.slice(1)}`; | |
| const methodName = `handle${argTypeToTitleCase}`; | |
| this[methodName](); | |
| } | |
| handleString() { |