Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,596 members, 7,809,161 topics. Date: Friday, 26 April 2024 at 02:07 AM

Help On Javascript Console - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Help On Javascript Console (360 Views)

Is It Necessary To Read A Book On Javascript? / Companies Working On Javascript Framework / Good Book On Javascript (2) (3) (4)

(1) (Reply) (Go Down)

Help On Javascript Console by stevedeey(m): 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

7 Likes 1 Share

Re: Help On Javascript Console by stevedeey(m): 7:08pm On Nov 22, 2020
Thanks so much @contributors. I realised to get 4, I'd need to introduce brackets

3 Likes 1 Share

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.

1 Like

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]

2 Likes

(1) (Reply)

Top Trends Influencing Wearable Mobile App Development In 2021 / Microsoft 365 And Azure study Group / Do You Love Coding?

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 12
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.