Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Other reasons that solution puts me off a little:

1. You have a dangling check for empty string at the end to set to the current number if the string is empty after the Fizz/Buzz conditions. An "else" clause disguised as an "if" clause.

2. It's just messier to understand. "If % 3, append Fizz; if % 5, append Buzz" has four different outcomes: neither matches, first matches, second matches, both match. A newcomer to the code has to mentally separate out all possibilities (which basically requires re-scanning the same code four times). Whereas the "if, elseif, elseif, else" can be read over and understood with a single scan.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: