Help On Javascript Console - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Help On Javascript Console (510 Views)
| 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: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: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: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: |
Is It Necessary To Read A Book On Javascript? • Companies Working On Javascript Framework • Good Book On Javascript • 2 • 3 • 4
Why Are All These Things Hidden • Want To Learn Node.js But Finding It Difficult?? Pin This Thread • In Urgent Need Of A Web Scrapper