Why is the boolean out of this code in JavaScript | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

Why is the boolean out of this code in JavaScript

"green"==" green" and "green"<" green"

8th Aug 2018, 11:26 PM
George S Mulbah II
George S Mulbah II - avatar
2 Respostas
0
"green" does not equal to " green" due to the space, "green" < " green" is undefined and will give you an error.
9th Aug 2018, 5:28 AM
Eldar Bakerman
0
Eldar Bakerman JS will compare the corresponding charcode of each string first character. "g" has a charcode of 103, and "<space>" has a charcode of 32. The output is false, not undefined, and no error is thrown. let a = "green" == " green" // False let b = "green" < " green" // False let c = a && b // False Not sure what the question means by "boolean out of this code" though.
9th Aug 2018, 5:54 AM
HoĆ ng Nguyį»…n Văn
HoĆ ng Nguyį»…n Văn - avatar