DEV Community

Cover image for Road to Genius: beginner #9
Ilya Nevolin
Ilya Nevolin

Posted on

Road to Genius: beginner #9

Each day I solve several 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, but you will learn a ton of new and interesting things as you go.

programming challenge

This challenge is a bit more complex than all previous ones we had. Solving it is very easy because you don't need to fully read the code. We need to fix the bug 💧, which is used near the end of the code. It seems to be just a variable name, whose value is obtained from calling a function. To find 💧, we can look at the next line, where there's a variable out which hasn't been declared yet, so 💧 has to be out.

programming challenge answer

Solving the challenge was a piece of cake, but let's analyze the code, in particular the function range. This function takes two arguments x and y. It declares an empty array, then there's a while-loop which runs as long as x < y. Inside the loop, it adds a number to the array which is x + arr.length, and then it increments x's value by one. Finally it returns the array arr. So 💧 (=out) points to the array (by reference).


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

Latest comments (0)