While loop not showing on console log


#1

I’m on exercise 6/8 in loops and while codeacademy program marked my code as correct , I don’t understand why only the last console.log is showing and not all the different cards it goes through to find the spade. Could someone please explain?


#2

Follow the logic of your code. Act like you are explaining it to a rubber ducky.
Create a variable called currentCard, set it equal to ‘sade’
While that variable currentCard isn’t equal to spade (aka never)
log currentCard (this would log spade if the cpu ever got here)
set currentCard to a random suit
Outside the loop now

log ‘Found a spade’
Your while loop is never even stepped into, if it was there would still be trouble


#3

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