๐
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
| /* ******************** If Else ********************* */ | |
| const integer =7; | |
| let resp = ''; | |
| if (integer >= 10) { | |
| resp = '2 digit integer'; | |
| } else { | |
| resp = '1 digit integer'; | |
| } |
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
| /* ******************** If Else/Switch Way ********************* */ | |
| const shape = 'circle'; | |
| const getArea1 = () => { | |
| if (shape === 'circle') { | |
| getCircleArea(); | |
| } else if (shape === 'triangle') { | |
| getTriangleArea(); | |
| } else if (shape === 'rectangle') { | |
| getRectangleArea(); |
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
| // Polyfill for Promise() | |
| // ----------------------------- | |
| // Syntax Example | |
| // const p = new myPromise(resolve, reject); | |
| const myPromise = function (executer) { | |
| let onResolve, onReject, | |
| isFulfilled = false, | |
| isCalled = false, | |
| value; |
OlderNewer