73

You vs the guy she tells you not to worry about

Comments
  • 10
    var biggerNumber = Math.max(a,b);
  • 0
    var a = 'a';
    var b = 'c';

    Math.max(a,b) // Nan
    biggerNumber(a,b) // 'c'

    Sorry brah! :)
  • 6
    @aswinramakrish The thing is called biggerNumber. The second it gets fed letters I'd assume something has gone really, really, really wrong.
  • 1
    Are you saying 'a' is not a number?
  • 1
    But 'a' is a number... Just not in base10! How should the program know in which base we're in?
  • 0
    I'm not sure what base 10 has to do here. In JS, 'a' < 'c' translates to 'a'.charCodeAt(0) < 'c'.charCodeAt(0) which is 97 < 99. So you can't really say 'a' and 'c' aren't numbers especially when it comes to comparisons. Even ' ' has a number value associated with it.
Add Comment