A quiz about type-coercion, indexOf return values, and the principle of lol whoops a bug.

03 Mar 2014

Given the following version method, and assuming a.User.device() returns the string "android", what is the return value assuming navigator.userAgent is:

Mozilla/5.0 (Android; Mobile; rv:30.0) Gecko/30.0 Firefox/30.0?

version: function() {
  agent = window.navigator.userAgent;
  switch (a.User.device()) {
    ...
    case "android":
      return window.Number(agent.substr(agent.indexOf("Android ") + 8, 3));
    ...
  }
}

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

The answer is NaN, obviously.

Debbie Downer