 A Place Of Growth. We Strive To Help You Sharpen Your Skills In Engineering and Programming. We Work Hard To Provide The Answers You are Looking for in Programming and Engineering/ Yes, Javascript follows the order of operation popularly known as BODMAS. I wrote a very simple program in Javascript to try this out, and prove it. You can follow along in the demonstration below.

We will try to evaluate the following to see if the results match.

3^2 + 9 x 7 – 12 ÷ 4

9 x (24-4)÷5+3^2

Let’s start with the first one: According to BODMAS (Bracket, Order, Division, Multiplication, Addition, Subtraction), we will start with 3 to the power 2, followed by 12 divided by 4, then 9 multiplied by 7, and finish off with additions and subtraction.

3^2 = 9, we have 9+9×7-12÷4

12÷4 = 3, we 9+9×7-3

9×7 = 63, 9+63-3

finally, 9+63-3 = 69

So, using BODMAS, we get 69 as the answer to 3^2 + 9 x 7 – 12 ÷ 4

Now, let’s do it using a simple Javascript program, note that Math.pow(3,2) is 3^2

``````<script>
</script>``````

When you run the program and check your console, the result will be 69 as shown in the screenshot below.

Let’s consider the second one with brackets: 9 x (24-4)÷5+3^2

by following BODMAS, we will start with (24-4), followed by 3 to power 2, and so on.

(24-4) = 20, we have 9×20÷5+3^2

3^2 = 9, we have 9×20÷5+9

20÷5 = 4, we have 9×4+9

9×4 = 36, we 36+9

finally, we have 36+9 = 45 which is the answer to 9 x (24-4)÷5+3^2 according to BODMAS.

We can do this one as well with a simple Javascript program shown below

``````<script>