Search code examples
javascriptdeepequals

Error comparing arrays using deepEqual. What is my mistake and why?


Can't find why it runs a deepEqual error, and unfortunately I only have this partial error log file. (The test code is not mine).

Statement: We want to write a function suitTrue, which given a suit, returns a list of strings, one for each card of that suit following as truco cards. Cards include all numbers except cards 8 and 9.

My Code:

function SuitTrue(suit) {
  var answer = [];
  for (var i =1; i<8; i++){
    answer.push( i + " of "+ suit);
  }
  for(var i = 10; i<=13; i++) {
    answer.push( i + " of "+ suit);
  }
  return answer;
}

Available teste error:

[ '1 of clubs',
  '2 of clubs',
  '3 of clubs',
  '4 of clubs',
  '5 of clubs',
  '6 of clubs',
  '7 of clubs',
  '10 of clubs',
  '11 o deepEqual [ '1 of clubs',
  '2 of clubs',
  '3 of clubs',
  '4 of clubs',
  '5 of clubs',
  '6 of clubs',
  '7 of clubs',
  '10 of clubs',
  '11 o

Solution

  • The test they used was wrong, only going up to the twelfth card.

    my apologies.