Javascript Mission 3: Math time!

Time for a math test. This time faith is aiming to test our math skills. Lets see, what she has got for us.

var foo = 5 + 6 * 7
var bar = foo % 8
var moo = bar * 2
var rar = moo / 3
function check(x)
{
     if (x.length == moo)
     {
           alert("win!");
           window.location += "?lvl_password="+x;
     } else {
           alert("fail D:");
     }
}

After checking out the source code, you can see that the length of the word you will enter is passed to function check which is then compared to moo. So, lets just find out moo.

After calculations you will find that, variable foo has the value 47 and variable bar has value of 7. How? ‘%'(percentage sign) in almost all programming languages is used as modulus, which is used to find the remainder, here 47 divided by 8 gives remainder 7. And therefore moo has the value of 14. Any string with the length of 14 will do.

Good luck!!!

Follow me

Abhishek Gupta

I am Abhishek from Lucknow (India). I have been working as a software engineer from last 6+ years, and its my passion to learn new things and implement them as a practice.
Follow me

Latest posts by Abhishek Gupta (see all)

2 Replies to “Javascript Mission 3: Math time!”

Leave a Reply