could somebody explain such expression
var a = (1.5-1)*2 correct answer is 8
how does this expression calculate?
It evaluates to
1. You evaluate first those inside the parentheses.
1.5 - 1 equals
0.5, then you multiply it by
2, so you have
first this code evaluates the bracket in this case it is 1.5-1.0 = 0.5, then it is multiplied by 2 giving the answer 1 not 8.
yes and I think so tha correct answer is 1 but I have met such quize on faceebook
and all answers was that correct is 8!
do not trust the facebook’s quiz posts:smiley:
Thanks, now I know that such quiz is rubbish
Is it possible, that you have a typo in your example?
var a = (1,5 - 1) * 2 will give you
I have seen again the quiz
and question was var a = (1,5-1)*2;
not var a =(1.5-1)*2;
correct answer 8