cjxsam
1
Hello, can anyone please help me with the while loop code
Here is the link to the lesson: https://www.codecademy.com/courses/introduction-to-javascript/lessons/loops/exercises/while
And here is my code: const cards = [‘diamond’, ‘spade’, ‘heart’, ‘club’];
// Write your code below
let currentCard;
while (currentCard = card[Math.floor(Math.random() * 4)])
If possible please help me
Thanks
If you post code, please make sure it is formatted: How do I format code in my posts?
Then, to get closer to a working code snippet, let’s start with the syntax for a while loop:
while( a condition is fulfilled ) {
do what is inside the curly braces
}
Can you take that snippet and write in your own words what you want your code to do?
2 Likes
cjxsam
3
i just do not understand
Code: `const cards = [‘diamond’, ‘spade’, ‘heart’, ‘club’];
// Write your code below
let currentCard;
while (‘spade’ !== currentCard) {
= card[Math.floor(Math.random() * 4)];
}
cjxsam
4
sorry i did not format my code, i do not understand how to
mtrtmk
5
Have a look at: [How to] Format code in posts
Basically, you can click on the </>
button in the forum post editor, and then copy paste your code in between the pair of three backticks,
```
copy paste code here
```
1 Like
cjxsam
6
ok, thanks a lot for your help