5 ms·
If that's the case, you can solve FizzBuzz using a declarative style in JavaScript, surely? It's pretty trivial in Haskell, which is declarative all over.
by mathw 7y ago
If that's the case, you can solve FizzBuzz using a declarative style in JavaScript, surely? It's pretty trivial in Haskell, which is declarative all over.
- _bxg1 7y agoIt's a little more natural in languages like Haskell and Python that have range generators; JS doesn't. You can do a hack where you initialize a sized array and then map over its indices, but that's unusual. Part of it may have been that the problem description I read used very imperative language. It didn't say "return a list of Fizz, Buzz, and FizzBuzz", it said "for each number that's ___, print X". Very side-effect-y.
- _bxg1 7y agoAnother thing is modulus. I know off the top of my head that mod == 0 means a number is divisible by another number because we used it all the time in my college programming assignments. People without a formal background may not even know what modulus is; there are lots of programming domains where it's not really useful.
- LyndsySimon 7y ago> there are lots of programming domains where it's not really useful. Off the top of my head, I can't think of any. Even if all you're doing is a simple CRUD app, alternating attributes on a list you're outputting to HTML is easily done with `if i % 2`.
- _bxg1 7y agoI'd do that particular case with CSS In five years since graduating I haven't used modulus outside of toy code challenges