While syntax


#1


https://www.codecademy.com/courses/javascript-beginner-en-ASGIv/0/2?curriculum_id=506324b3a7dffd00020bf661


It crashes the page when I click 'Save & Submit Code', thanks for any help x


var understand = true;

while(understand=true){
	console.log("I'm learning while loops!");
	understand = false;
}


#2

When you use only one = that is interpreted as an assignment character. To check if something is equal to something else use either == or ===. In this case if you want to check if understand is true you can just use while (understand) and java-script knows that you mean while (understand == true).


#3

thank you, this worked xx


#4

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