Not understanding the while loop completely


#1

Hi there,

I am quite new with the whole coding thing. I do not quite understand this exercise. It's working but it says that the while loop is guessing a card, then seeing if it is a Spade, over and over, until it finds one.

But isn't that just because of the console.log statement outside of the while loop? Am I overthinking things? Is the while loop supposed to get tell me when it found a spade?

This is what it looks like:

Can someone please help? :slight_smile:

Exercise: Arrays and Loops, while loops, page 6/7


#2

the while loop will keep running until it finds a spade, the console.log is only there to log the console the card that is found.


#3

You aren't printing out the last one (has to do with the order you do things, not really anything to do with code)

The loop stops at spade, so therefore it's safe to say that after the loop has stopped, a spade was found


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.