FizzBuzz!



You walk into an office, excited that you won an interview. The company is doing good work, the dev team builds interesting things, and you would really love to get this job.

 

Then you look up, and see a giant white board on the wall. Someone hands you a marker, points you toward the board, and says, “Ok, solve Fizz Buzz for us.”

 

It’s the stuff Junior Dev nightmares are made of!

 

I’ll admit to a moment of trepidation when we learned we’d be working out a Fizz Buzz exercise. But I was also excited, because JavaScript code challenges are everywhere and I knew I had to get familiar with them.

 

As it turned out, this code challenge was a lot of fun. Using ternary expressions whittled the For loop down to basically one line (!), and we got our first shot at input validation.

 

Since Fizz Buzz performs math, we needed to make sure our user could only enter numbers in the input fields. Using a “keydown” function and event key codes to only accept input from certain keys on the keyboard took care of that. 

 

Even though I’m satisfied with my work, I’ve definitely got an upgrade planned for my Fizz Buzz app: the results display! When I have a little down time after graduation, I plan to drastically improve the display - at least some color and a better table.

 

For now, I have a good Fizz Buzz solution and I’m focused on upcoming projects.


Post Comments

Leave a comment.