DEV Community

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

Posted on


Road to Genius: beginner #10

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 starts with the declaration of a function mystery, with one parameter arr which is likely an array. After the function it creates an array, then calls the function, whose result goes into variable A. Fortunately we don't have to calculate everything this code does, but only have to fix two bugs (😈 and 🚀). To find 🚀 you can analyze the first three lines of code of the function, it starts with initializing variable S=0, then later we see 🚀 += i, so 🚀 is likely going to be S. Then the next line is S /= arr.😈;, 😈 seems to be a property of the array object, the only valid property from the answers seems to be length.

programming challenge answer

If you analyze more closely at what mystery actually does: it's summing all values from arr into S, and then it divides this sum by the length of the array. In other words it's computing the average value of all the numbers in arr.

If you feel inspired and motivated to upgrade your coding + debugging skills, join me on the Road to Genius at

Top comments (0)

Visualizing Promises and Async/Await 🤯

async await

Learn the ins and outs of Promises and Async/Await!