You shouldn’t terminate the first line with a ;
var goSleep=function();// goSleep Function
// -------------------^ Remove this!!!
{
var count=0;
var loop=false;
while(count<3) //while loop
{
console.log("hi!");
count++;
loop=false;
}
for(i=0;i<4;i++) //for loop
{
console.log(i);
}
var login=false;
do{//do while loop
console.log("gud day");
}while(login);
};
goSleep();
Change your code to:
var goSleep=function() // goSleep Function
{
var count=0;
var loop=false;
while(count<3) //while loop
{
console.log("hi!");
count++;
loop=false;
}
for(i=0;i<4;i++) //for loop
{
console.log(i);
}
var login=false;
do{//do while loop
console.log("gud day");
}while(login);
};
goSleep();
0
solved Unexpected token error in JS function