r/code • • Mar 11 '20

Code Question

I am going to be attending General Assembly and was working on the prework.

Here are my current instructions:

Next we'll add logic to check to see if two cards have been played, because in our final game we will not want to check for a match until the user has selected two cards.

  • Write an if
    statement that checks to see if the length of the cardsInPlay array is 2.

  • For the condition, you can use the length
    property to find out how many items are in the cardsInPlay
    array and then use the ===
    operator to see if the length is equal to 2.

I've got the first part of the if statement, but I am clueless on what they want for the rest of it. Next step is putting an if statement in the if statement...which wasn't hard or a problem. It's this that is making me stuck. Help?

0 Upvotes

3 comments sorted by

3

u/[deleted] Mar 11 '20

I'm interpreting this as all one problem. They are introducing what needs to be done and then being more specific on how to get it done.

To me it seems like they want you just to write whatever is equivalent to this:

if(cardsInPlay.Length === 2)

2

u/Poddster Mar 12 '20

This is garbled nonsense. You're presenting us with a random fragment of your homework, giving us vauge ideas of what work you've attempted to solve this and are now asking us to solve it for you. But that's impossible as we're completely contextless. E.g. You haven't even told us what programming language it is.

1

u/TechLaden Neo Mar 12 '20

Probably JS since the OP mentioned ===. What you've said is definitely true though; this is a very bigger question, asking you how to use an if statement.