0
Javascript beginner challenge query
Hey What is is the answer to ((“1”)-1==0) I thought it was a type error but the challenge says true Someone please explain
3 Respuestas
+ 2
When retrieving a value from a string value and a integer, the string value is automatically converted to an integer value. For instance, "1" == 1 would return true because when comparing them it's automatically converted to an integer and also "2" - 1 would return 1. However, if you had "1" === 1 it would return false because === is comparing if they are the same value and of the same type. In your question, the parentheses around the string may just be there to make you think harder but could be ignored in this case. So with that said "1" - 1 would be 0. So the Boolean would be true.
+ 1
Thank you for the explanation!
0
Your welcome. I hope this helps.