$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · hard · #80

What is the correct fix?

enum Role { User, Admin }
function isAdmin(r: Role) {
  return r == Role.Admin || r;
}
  1. Return r === Role.Admin on its own
  2. Return r !== Role.Admin on its own
  3. Change the enum so User starts at 1
  4. Compare against the string 'Admin'
The trailing || r makes any non-zero role truthy; the comparison alone is the answer.
Play Problem Solving ▸