Hack This Site: Javascript Mission – Level 3

Introduction

Hello Internet, welcome to HaXeZ where today we’re going to be solving the 3rd Javascript mission on Hack This Site. Judge me how you will but I have to admit that I learned a lot from this challenge. My time at school was less than ideal so I didn’t go very often. Unfortunately, this meant I missed out on a lot of important subjects including mathematics. I hadn’t even heard of BODMAS until today and I’m 35. I have no idea how I’ve made it this far in computing without knowing it. This challenge is fairly simple provided you know how variables work and know maths.

Javascript Mission Level 3
Javascript Mission Level 3

The Javascript

Looking at the code below we can see that we need to submit a password that is the same length as the value of the variable ‘moo‘. We know this because of the if statement that requires ‘x.length == moo‘ for us to get the alert that we have won the mission. In order to get the value of ‘moo‘, we need to perform some calculations to work out the value.

Javascript Maths
Javascript Maths

The Mathamatics

Ok, let’s break down the maths.

The value of ‘foo‘ is 47 Because of the BODMAS calculation 6 * 7 + 5.

The value of ‘bar‘ is 7 Because it’s the Modulus remainder of 47 divided by 8

Therefore, the value of ‘moo‘ is 14 because the value of ‘bar‘ is 7 and the value of ‘moo‘ is ‘bar‘ * 2.

We can discard the value of ‘rar‘ because ‘rar‘ is not used anywhere during the calculation. Therefore, we are left with the value 14. We know that the password submission form requires our input to be the same length as ‘moo‘. In essence, we should be able to submit any 14 characters to complete the mission.

Submitting 14 Characters
Submitting 14 Characters

Congratulations

After submitting 14 characters to the password submission form, you should complete the challenge. That’s all there is to it. However, if you don’t know about BODMAS, which I didn’t, and if you didn’t know that a percentage sign in programming means Modulo or remainder then it could be difficult.