Last active
September 20, 2019 05:48
-
-
Save Luftare/04fe10b576332f56ebd1a26d49632ac9 to your computer and use it in GitHub Desktop.
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 DotComment { | |
constructor() { | |
this.comment = ''; | |
const lowerCaseAlphabets = 'abcdefghiklmnopqrstvxyzåäö'.split(''); | |
const specialCharacters = '_'.split(''); | |
const upperCaseAlphabets = lowerCaseAlphabets.map(char => | |
char.toUpperCase() | |
); | |
const characters = [ | |
...lowerCaseAlphabets, | |
...upperCaseAlphabets, | |
...specialCharacters, | |
]; | |
characters.forEach(letter => { | |
Object.defineProperty(this, letter, { | |
get() { | |
const decodedLetter = letter === '_' ? ' ' : letter; | |
this.comment += decodedLetter; | |
return this; | |
}, | |
}); | |
}); | |
} | |
qst() { | |
this.comment += '?'; | |
return this; | |
} | |
exl() { | |
this.comment += '!'; | |
return this; | |
} | |
log() { | |
console.log(this.comment); | |
} | |
} | |
new DotComment().T.h.i.s._.i.s._.a._.l.i.t.t.l.e._.s.i.l.l.y.exl().log(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment