Skip to content

Instantly share code, notes, and snippets.

@MitMaro
Last active September 22, 2017 16:16
Show Gist options
  • Save MitMaro/c92f282e734397339eb4c2da8a1003b3 to your computer and use it in GitHub Desktop.
Save MitMaro/c92f282e734397339eb4c2da8a1003b3 to your computer and use it in GitHub Desktop.
FizzBuzz constructor fun
'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));
@jackharrhy
Copy link

spectacular.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment