Fizz…Buzz…FizzBuzz? This classic and fun little technical interview question will really tackle your understanding of the modulus operator!
FizzBuzz is a pretty simple interview question that comes up often. It’s one of those questions that after you see the answer once, you’ll always remember how to solve it from then on out. The only tricky part about this entire problem is the usage of the modulus operator. According to the MDN Web Docs, the modulus/remainder operator (%) returns the remainder left over when one operand is divided by a second operand. It always takes the sign of the dividend. So if I write 12 % 5, it will return 2 because 5 goes into 12 twice with a remainder of 2. With that said, let’s get started:
Write a function that prints out a number from 1 to x. However, you must abide by these rules:
For every multiple of 3, print “fizz” instead of the number.
For every multiple of 5, print “buzz” instead of the number.
For every multiple of both 3 and 5, print “fizzbuzz” instead of the number.
For example, fizzBuzz(5) will return:
1 2 fizz 4 buzz
Who else loves to write side-effects-free functions? I think we, as programmers, all do. Today, in this story, I will walk you through the basic principles of functional programming that will make your coding life easier.
I previously wrote about some common coding algorithms that you’ll run into on your job search. The article was received fairly well so I thought I’d do a couple more to help in your journey to becoming more familiar with algorithms.
This tricky Kadane’s Algorithm with a deceptively simple solution is a great introduction to more optimal problem-solving practices. Continue ...
This article will introduce the concepts and topics common to all programming languages, that beginners and experts must know!