Last active
September 22, 2017 16:16
-
-
Save MitMaro/c92f282e734397339eb4c2da8a1003b3 to your computer and use it in GitHub Desktop.
FizzBuzz constructor fun
This file contains 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
'use strict'; | |
Array.from(Array(100)).map((_, i) => { | |
return (new (class FizzBuzzSolver extends ( | |
(index) => { | |
if (index % 3 && index % 5) { | |
return class Index {constructor() {this.value = index}}; | |
} | |
else if (!(index % 3 || index % 5)) { | |
return class FizzBuzz{constructor() {this.value = 'FizzBuzz'}}; | |
} | |
else if (!(index % 5)) { | |
return class Buzz {constructor() {this.value = 'Buzz'}} | |
} | |
else { | |
return class Fizz {constructor() {this.value = 'Fizz'}} | |
} | |
} | |
)(i+1) { | |
constructor() {super(); this.v = () => this.value;} | |
})).v(); | |
}).forEach((v) => console.log(v)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
spectacular.