Welcome, Guest: Join Nairaland / LOGIN! / Trending / Recent / New
Stats: 2,598,437 members, 6,030,939 topics. Date: Friday, 04 December 2020 at 12:42 AM

Help On Javascript Console - Programming - Nairaland

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

How Did You Learn 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
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
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
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
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
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
404Dev:
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

2 Likes

(1) (Reply)

Www.vacancy.customs.gov.ng / Using International Debit Cards On Quickteller / Please Help A Brother In Need, With Laptop Or Desktop For Programming.

(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 - 2020 Oluwaseun Osewa. All rights reserved. See How To Advertise. 31
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.