mercredi 29 avril 2015

if/else statement is correct, but not returning incorrect

These are my instructions:

have four arguments that are all number

return "correct" if the four numbers are a valid combination

return "incorrect" if the 4 numbers aren't a valid combination a combination is valid if:

  • the first number is a 3, 5, or 7

  • the second number is 2

  • the third number is between 5 and 100. 5 and 100 are both valid numbers

  • the fourth number is less than 9 or greater than 20. 9 and 20 both invalid numbers

This is my code:

module.exports.checkLock = function(a, b, c, d) {

    if (a === 3 || 5 || 7, b === 2, c >= 5 || c <= 100, d < 9 || d > 20) {

        return "correct";
    }
    else {
        return "incorrect";
    }
};

And this is the error I am getting:

1) checkLock should return 'incorrect' for the incorrect first number example:

  AssertionError: expected 'correct' to deeply equal 'incorrect'
  + expected - actual

  +"incorrect"
  -"correct"

  at Context.<anonymous> (spec.js:39:49)

2) checkLock should return 'incorrect' for incorect second number:

  AssertionError: expected 'correct' to deeply equal 'incorrect'
  + expected - actual

  +"incorrect"
  -"correct"

  at Context.<anonymous> (spec.js:43:49)

3) checkLock should return 'incorrect' for invalid third numbers:

  AssertionError: expected 'correct' to deeply equal 'incorrect'
  + expected - actual

  +"incorrect"
  -"correct"

Any help would be appreciated. Also, sorry about formatting.

Aucun commentaire:

Enregistrer un commentaire