Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For those wondering:

  setDisplayMessage() {
  switch(true) {
  case(this.difference <=1000):
    return 'Looks like you basically have no idea how long 5.5 seconds is.';
  case(this.difference <=2000):
    return 'I mean, you can do better. :D';
  case(this.difference <=3000):
   return 'You are getting the hang of it. Sort of.';
  case(this.difference <=4000):
   return 'As they say, it could have been worse.';
  case(this.difference <=5000):
   return 'Super close!';
  case(this.difference <=5250):
   return 'DOH! You almost had it.';
  case(this.difference <=5375):
   return 'Great score!!!';
  case(this.difference <=5499):
   return 'NICE!!!';
  case(this.difference <=5500):
   return 'YOU DID IT YOU DID IT YOU DID IT YOU DID IT I CAN\'T BELIEVE IT!!!!!';
  default:
   return 'Aaand just like that, you went over.';
  }


That’s an… interesting usage of a switch block…


elif is for suckers, but a COND by any other name...


    setDisplayMessage() {
        if (this.difference <= 1000) return 'Looks like you basically have no idea how long 5.5 seconds is.';
        if (this.difference <= 2000) return 'I mean, you can do better. :D';
        if (this.difference <= 3000) return 'You are getting the hang of it. Sort of.';
        if (this.difference <= 4000) return 'As they say, it could have been worse.';
        if (this.difference <= 5000) return 'Super close!';
        if (this.difference <= 5250) return 'DOH! You almost had it.';
        if (this.difference <= 5375) return 'Great score!!!';
        if (this.difference <= 5499) return 'NICE!!!';
        if (this.difference <= 5500) return 'YOU DID IT YOU DID IT YOU DID IT YOU DID IT I CAN\'T BELIEVE IT!!!!!';
        return 'Aaand just like that, you went over.';
    }
elif is for suckers indeed




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: