DEV Community

Cover image for Road to Genius: smart #16
Ilja Nevolin
Ilja Nevolin

Posted on

Road to Genius: smart #16

Each day I solve several coding challenges and puzzles from Codr's ranked mode. The goal is to reach genius rank, along the way I explain how I solve them. You do not need any programming background to get started, and you will learn a ton of new and interesting things as you go.

coding challenge

Let's jump right to it. We need to fix one bug 🐼, which should be an identifier (most likely a variable name). The code starts with a function canJump. If you analyze the code, it seems some strange algorithm that returns a boolean value. Fortunately we don't have to fully understand the code to complete the challenge.

Let's focus on the buggy line which is in the form of max = Math.max(a, b). This is a very common line of code for keeping track of the largest/max value while iterating an array. In our simplified form, the code returns a if a > b otherwise it returns b. In our challenge code, a is given, and b is 🐼. The code is likely going to compare a with the current max value. So 🐼 must be max:

coding challenge answer


If you feel inspired and motivated to upgrade your coding + debugging skills, join me on the Road to Genius at https://nevolin.be/codr/

Top comments (0)