DEV Community

Discussion on: [Challenge] 🐝 FizzBuzz without if/else

Collapse
 
guillaume_agile profile image
craft Softwr & Music

My 10 cents:
you should have said: FizzBuzz with a Cyclomatic Complexity to maximum 2 (or 1).
Because if you replace a if/else by Logical Operators, or Switch or While or For, you aren't doing better code in terms of Cyclomatic Complexity

The CSS approach is one of the most elegant.
Another one without any cyclomatic complexity is acheived with a strong type system, like what you can do in Haskell, F#; Kotlin or TypeScript
See that solution (not mine, but clever if you understand the type inference mecanism) gist.github.com/na-o-ys/34e9ebf7fc...