Review Only shows unexpected token


#1

// Write your code below!
for(var i = 69; i >= 33; i-=9) {
console.log(i);
};
var fuckMe = function() {
fuckMe === true;
do {
console.log("Double -ve" + " " + fuckMe);
}; while(fuckMe)
}
fuckMe(false);

and shows Oops, try again. There was a problem with your syntax.


#2

Sorry,this is the complete code

// Write your code below!
for(var i = 69; i >= 33; i-=9) {
console.log(i);
};
var fuckMe = function() {
fuckMe === true;
do {
console.log("Double -ve" + " " + fuckMe);
}; while(fuckMe)
}
fuckMe(false);
var condition = true;
while(condition) {
console.log("Whyyyyy?");
condition = false;
}


#3

That semi-colon there, remove it but this your code could crash the browser.


#4

Removed that ; and the first loop seems to work now.
Shows type error : true is not a function. Think I can fix that.
Thank you, you the mvp


#5

You welcome. I have adjusted some more syntax errors like positions for the semi-colon.But you see, that last while loop is gonna run to infinity. Maybe write a for loop to specify boundary or a do before it.

for(var i = 69; i >= 33; i-=9) {
console.log(i);
}
var fuckMe = function() {
fuckMe === true;
do {
console.log("Double -ve" + " " + fuckMe);
} while(fuckMe);
};
fuckMe = false;
var condition = true;
while(condition) {
console.log("Whyyyyy?");
condition = false;
}

Let me suggest you do something like this for the last loop:

var condition = true;
do {
    condition--;
}
    while(condition); {
    console.log("Whyyyyy?");
       condition = false;
        }

Hope this helps! :slight_smile:


#6

Could you explain condition-- please?


#7

Simply put,

is a negative incremental.

Let me use numbers to explain it.

    var text = ""
    var i = 0;
    do {
        text += "<br>The number is " + i;
        i++;
    }
    while (i < 10)

You see, the above will yield:

The number is 0
The number is 1
The number is 2
The number is 3
The number is 4
The number is 5
The number is 6
The number is 7
The number is 8
The number is 9

Because I told it to do textas that but incrementing it positively (i++;). Then thewhile loop which should be true, stops the loop from going infinitely.

I hope I did justice to your question. :slight_smile:


#8

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