Sitemap

Fibonacci in JavaScript (What I learned from a Failed Interview)

3 min readAug 27, 2024

Note: This was written in 2015.

I recently had an interview where I was asked to write a small program that output a Fibonacci series on the spot. It had been a long time since I’d tackled a math puzzle — probably not since college — so I was immediately gripped by nervousness. Unfortunately, I didn’t perform well and wasn’t called back for the fourth interview.

As an engineer, I naturally broke down the interview and analyzed what went wrong. The first issue was my choice of programming language. I opted for Java, my favorite language, but one I hadn’t actively used in six years. Coding, as it turns out, is not like riding a bike — you don’t just learn once and remain proficient forever. If you don’t code regularly, your skills can fade quickly. This became painfully obvious when I opened my latest install of Eclipse IDE. A language that had once felt second nature to me now seemed completely foreign.

I no longer code on a regular basis, and when I do, it’s usually minor modifications to existing code or something quick in HTML5 and JavaScript. Staring at the blank project screen, I felt a wave of panic.

Though I didn’t advance to the next round of interviews, I walked away with a valuable insight: my coding skills had atrophied. Determined to address this, I started dedicating my spare time to coding again. I began with the Fibonacci sequence, but this time in the language I’ve been actively using — HTML5 and JavaScript. I needed to prove to myself that I could still do it.

Get Johnny J’s stories in your inbox

Join Medium for free to get updates from this writer.

I used JSFiddle to work on the code both at work and at home. You can check out the result here:

JS Fiddle here

If you’re looking to gain coding experience or keep your skills sharp, I highly recommend JSFiddle. It’s a useful sandbox that you can access from any HTML5-ready browser (I prefer Chrome). There’s also a similar environment for SQL coding at SQLFiddle. Both are accessible from most internet connections.

Happy coding!

While this was originally written on July 11, 2015, the lesson I learned that day remains relevant to me today. It’s been nine years, and I still get nervous when faced with the whiteboarding portion of an interview. Just like back then, I might freeze or draw a blank. I first posted this on my GitHub blog, but I wanted to share it somewhere more accessible now.

Since that day, I’ve changed my approach when learning a new programming language. Instead of starting with a typical “Hello, World” program, I now begin with a “Hello, Fibonacci” as a tribute to the interview I struggled with so long ago.

One final thought: coding is like running a marathon. If you train every day and work out regularly, the journey may be challenging at times, with its ups and downs, but in the end, you’ll cross the finish line. However, if you spend years just thinking about training, without actually doing it, you might find yourself unable to make it through the first mile.

Johnny J
Johnny J

Written by Johnny J

Just another software engineer trying to keep my coding skills relevant in an age where technology is changing at an ever quickening pace.