While Loops


#1

Someone could explain to me why is not working (3rd part)?

https://www.codecademy.com/courses/learn-javascript-loops/lessons/loops/exercises/while?action=lesson_resume&course_redirect=introduction-to-javascript

let cards = [‘Diamond’, ‘Spade’, ‘Heart’, ‘Club’];
let currentCard = ‘Spade’;
while (currentCard !== ‘Spade’) {console.log(currentCard);
let randomNumber = Math.floor(Math.random() * 4); currentCard = cards [randomNumber];}


#2

SyntaxError: Unexpected character ‘‘’ (1:13)

Replaced the ‘ with ', and…

SyntaxError: Unterminated string constant (1:13)

Replace the ’ with ', and…

SyntaxError: Unexpected character ‘‘’ (1:24)

If you composed this code yourself, then you simply used the wrong quote characters. You’ll need to fix the above code to use either ' or " as quotes.


#3

I am sorry but I do not understand what you mean?


#4

What do you not understand? Did you copy the code that you pasted in to your question? If so, that would explain the non-standard punctuation.

Usually the single quote, ' and double quote, " are found on the same key, the latter being shifted.

The left-single-quote and right-single-quote are non-standard and not recognized by code parsers.


#5

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