10/11 please asap


#1

why does this code not work, i already have a code that does work but i dont understand why this specific coding does not work:

var myCondition = true;
var getToDaChoppa = function(){
// Write your do/while loop here!
do {
console.log("Print only once if condition is" + myCondition + ".");

} while(myCondition) {
console.log("Print twice if condition is + "myCondition");
myCondition = false;
}
};

getToDaChoppa();


#2

Well this is not how do while loops work. If you have a look at the syntax you see that this is the do while loop:

do {
      console.log("Print only once if condition is" + myCondition + ".");

} while(myCondition)

which is an infinite loop as myCondition is true and is never changed in the progress. And the part in unnecessary {} after this is just regular code that is in no way connected to the loop.


#3

you forgot to complete the string here by putting "

"Print twice if condition is"

and also, don't put myCondition in "" , since its a variable!
Hope this resolves your problem!
Have fun coding!


#4

ok thank you very much both of you, so is arcninja56670 explanation above right or wrong then, like would it work if i did what he/she told me to do?


#5

Well @arcninja56670 mentioned a problem that I'd missed that needs to be fixed as well but to make your code work you need to fix this and the while loop.