I'd like some feedback please!

I built this SpeedGrader recreation in JavaScript, so I thought some feedback would be useful for its improvement.

const scoreGrader = (score = null) => {
  score === null ? console.log('Your score is invalid.') : console.log(`Score: ${Math.round(score)}`);

  if (score >= 80) {
    console.log('You did awesome!!');
  } else if (score <= 70 || 75) {
    console.log('You tried!');
  } else {
    console.log('ERROR1: UNKNOWN RESULT');
  }
}
// this function prints and calculates the score.

scoreGrader();

If you see anything I could fix/improve, please tell me!!

I see a potential problem here:

else if (score <= 70 || 75) {

The number 75 is truthy
so it’ll be evaluated like true
so
(score <= 70 || 75)
will always be true (or something that acts like true for the if-statement condition)

1 Like

I get what you mean, but when I called the function with the parameter as 75, I got an error message from it.

else if (score <= 70 || 75)
should be
> else if (score <= 75)
right?
There is no need to say less than or equal to 70, and then less than and equal to 75. 
if the score IS less than or equal to 75 you still get the 'you tried'. 
1 Like

It worked! But there’s still a problem:
I think there’s a canvas between the numbers 75-80, that being 76-79 evaluate to the error message.

What i can read from your code is that if the score is 80 or above you win, if its less than 80 youve lost.

simple code:

if (score >= 80) {  // score is greater or equal to 80.
    console.log('You did awesome!!');
} else if (score < 80) {  // score is less than 80.
    console.log('You tried!');
}