It says unexpected token else, idk why :P


#1

var z = true

while(z){ 

    console.log("I like chocolate");

    z = false;     
    
    }
    
var x = 0    

for(x; x>10; x+=5){ 
    
    console.log("I'm going to be certified"); 
 
 else { 
     
    return "I'm going to be a tech and a comp scientist :P";

 }      }
 
 z();
 x();

can anyone tell me why ? : P


#2
var x = 0    

for(x; x>10; x+=5){

when x is 0 then x is not bigger than 10 so the loop would not run.

also you're using else without and if. And return without being inside of a function. That makes no sense else is the default case to a condition but without a condition there is no default case. And returns manages the jump back from a "sub program" (function) to the main program but if you're already in the main program where should it jump to.

Last but not least you try to calll x and z but both are functions so this will fail as well.