0

Why it’s return ā€œtruefalseā€? I think this is due to the nuances of data types

https://code.sololearn.com/W9jV9Wk4lIbM/?ref=app

3rd Jun 2020, 12:14 PM
Aleks
6 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!
3rd Jun 2020, 12:47 PM
Thống Nguyį»…n
Thống Nguyį»…n - avatar
+ 2
ThÓng Nguyên, ODLNT, thank you for the answers!
3rd Jun 2020, 12:56 PM
Aleks
+ 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
3rd Jun 2020, 12:21 PM
Thống Nguyį»…n
Thống Nguyį»…n - avatar
3rd Jun 2020, 12:50 PM
ODLNT
ODLNT - avatar
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
3rd Jun 2020, 12:35 PM
Aleks