Ilya Nevolin

Posted on

# Road to Genius: beginner #12

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.

Until now there weren't many decent challenges regarding strings. This challenge consists of three lines of code, but does require some attention, especially if you're new to coding and/or javascript.

We need to fix two bugs π§ and πΌ, both should be strings as required by the challenge. The third line of code goes like this: `R = (A + B)[2]`. It creates a variable `R` whose value is a "complex" string operation. The operation concatenates (combines) the string values of `A` and `B`, from this result it takes the character at index two. The challenge requires `R` to equal `k`, so this means we need to make sure that the 2nd character in the combined string is the character `k`. When we look at the possible options for π§, we can find only one answer that contains the character `k` at the 2nd index (or 3rd position). This value will ensure that the final condition is met; the value of πΌ is no longer important so we can choose pretty much anything.

Example:

``````let A = 'cuk'
let B = 'pap'
let R = (A+B)[2]    // similar to: R = 'cukpap'[2]
``````

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