0

how to join words in javascript. i don't understand the code below.

var a = "8a"; var b = 8; if (a<b) { document.write(a + " is less than " + b)

20th Jul 2020, 9:16 PM
Abubakar Sadiq Omokanye
Abubakar Sadiq Omokanye - avatar
1 Respuesta
+ 1
You can compare a string to a number only if the string's all letters are digits. For example, 8 == "8" 8 < "18" "7" > 3 will all return true. In the given code, the string is not fully composed of digits, so a < b will always be false and thus the code inside the if block will never be run.
20th Jul 2020, 9:56 PM
XXX
XXX - avatar