Math operations
I have a question ❓
According to my course based on numbers in JavaScript
//The first one
let dogAge = prompt("How old is the dog")
let humanAge = alert((dogAge - 2) * 4 + 21)
//The second one
let dogAge = prompt("How old is the dog")
let humanAge = alert(dogAge - 2 * 4 + 21)
Which one is correct because I gave JavaScript the first one and is giving me different answers which is not same with the second one
6 Replies
this is basic math question order of operation matter 😉
MDN Web Docs
Operator precedence - JavaScript | MDN
Operator precedence determines how operators are parsed concerning each other. Operators with higher precedence become the operands of operators with lower precedence.
I'll link this again here
Please use an appropriate title. “JavaScript” is vague enough to be useless
Now I understand
Tnx gee
Noted boss
I will use the correct title according to my question or problem
Back to mathematics
But JavaScript seems a little bit hard
This isn’t a JavaScript issue, it’s maths.