Unit 5: Lesson 8: Bubble 4



I understand that the comparison using operators underneath the line (line 15 and below) are not typical comparisons.

I am however wondering if the use of greater than and less than appearing false is just as the data types do not match (String < Integer etc). Is there anyway where those comparisons do/would work?


You are correct in that the type mismatch causes the condition to be false. Beyond the scope of this course is string conversion. The following would both evaluate to true:

var num = 3;
var n = num.toString();

var otherNum = parseInt(“3”);