₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,012 members, 8,419,929 topics. Date: Thursday, 04 June 2026 at 07:41 AM

Toggle theme

Help On Javascript Console - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingHelp On Javascript Console (510 Views)

1 Reply (Go Down)

Help On Javascript Console by stevedeey(op): 4:42pm On Nov 22, 2020
Following BODMAS rule, 9 - 4 + 1 should give me 4. I run same on Javascript console it returned 6 instead. Help, What am I missing?
Re: Help On Javascript Console by 404Dev: 6:16pm On Nov 22, 2020
stevedeey:
Following BODMAS rule, 9 - 4 + 1 should give me 4. I run same on Javascript console it returned 6 instead. Help, What am I missing?
bodmas is for mathematics. In javascript and programming operations move from left to right so its is 9-4 = 5 then +1 which is 6
Re: Help On Javascript Console by stanliwise(m): 6:43pm On Nov 22, 2020
stevedeey:
Following BODMAS rule, 9 - 4 + 1 should give me 4. I run same on Javascript console it returned 6 instead. Help, What am I missing?
9-4+1 does not give you 4 mathematically
It only gives you 6. Except you mean 9 - (4 + 1)

The verbose version of your calculation would be
+9-4+1

This means all numbers carry a sign at their front. So it would be wrong for you to assume

4 + 1 instead of -4 +1 which is more accurate
Re: Help On Javascript Console by stevedeey(op): 7:08pm On Nov 22, 2020
Thanks so much @contributors. I realised to get 4, I'd need to introduce brackets
Re: Help On Javascript Console by nagalee(m): 3:32am On Nov 23, 2020
stevedeey:
Following BODMAS rule, 9 - 4 + 1 should give me 4. I run same on Javascript console it returned 6 instead. Help, What am I missing?
using Bodmas, the result will still be 6 . It is -4 + 1 = -3. Then 9 - 3 = 6. Not 4 + 1 = 5 then 9 -5 = 4. So you applied bodmas wrongly.
Re: Help On Javascript Console by cixak95212: 10:18am On Nov 23, 2020
404Dev:
[s]bodmas is for mathematics. In javascript and programming operations move from left to right so its is 9-4 = 5 then +1 which is 6[/s]
1 Reply

Is It Necessary To Read A Book On Javascript?Companies Working On Javascript FrameworkGood Book On Javascript234

Why Are All These Things HiddenWant To Learn Node.js But Finding It Difficult?? Pin This ThreadIn Urgent Need Of A Web Scrapper