Re:Find the Bug in my Fizz Buzz Interview (2:47 video)
by AshFurrow on Thursday January 19, 2012 @11:25AM
(#3485130)
You're checking for a null local variable value in the third conditional, but appending to that same variable in the first two, which would either cause a runtime error in most languages or never pass the third conditional.
[ Parent
| on HN ]
Re:Find the Bug in my Fizz Buzz Interview (2:47 video)
by jpeterson on Thursday January 19, 2012 @11:30AM
(#3485153)
This was my first thought as well. If he instead initializes:
var result = "";
and checks for: if (result.length === 0) {
...
in the third conditional, is there still a bug?
Re:Find the Bug in my Fizz Buzz Interview (2:47 video)
by AshFurrow on Thursday January 19, 2012 @11:39AM
(#3485217)
Yes, he specifies the conditional is "examine the variable result; if it is still null ..."
Re:Find the Bug in my Fizz Buzz Interview (2:47 video)
by extension on Thursday January 19, 2012 @12:20PM
(#3485449)
In Ruby, for example, you could append a string to nil by interpolating the nil into a string literal, or various other ways. Seeing as he didn't specify the language, what the variable was initialized to, or what exactly "append" means, we can only assume that these imaginary things behave as intended.