New course! Every coder should learn Generative AI!
Try a free lesson0
Why it’s return “truefalse”? I think this is due to the nuances of data types
5 Answers
+ 1
Aleks this is a common problem in javascript calculations. Try console.log(0.1*0.2);
and you will see. Google javascript floating point precision for more info!
+ 2
Thông Nguyên, ODLNT, thank you for the answers!
+ 1
Aleks it's because === is a comparison operator. So it will return true or false. More info here: https://www.w3schools.com/js/js_comparisons.asp
+ 1
https://code.sololearn.com/WrixzjKbUTWD/?ref=app
https://stackoverflow.com/questions/11695618/dealing-with-float-precision-in-javascript
0
I mean - why first comparison return true, but second - return false. They have identical structure. The only explanation that i see is related to data conversion when moving to integer values