#8. when to while and when to for. syntax error


#1



I am stuck with question 8 I tried to write my ownish code but i am having troubles figureing out what i did wrong... ( I am canadian so we spell colour with an U) Can someone please help me?


SyntaxError: Unexpected token '{'. Expected ';' after var declaration.


var compliment = true
var complimentLoop = funtion(){
    while(compliment=true){
        console.log("You are so amazing!");
        compliment=false;
    }
}; 

complimentLoop();



var colours = ["purple", "red", "blue", "indigo", "green"];

for (var i=0; i<colours.length; i++){
    console.log("I like these colours" + " " + colours[i]);
};

#2

var compliment = true;
var complimentLoop = funtion(){ // function not funtion
 
    while (compliment=true) { // use == or === / = is for declaration 
        
        console.log("You are so amazing!");
        compliment= false;
    }
}
complimentLoop();



var colours = ["purple", "red", "blue", "indigo", "green"];

for (var i=0; i<colours.length; i++){
    console.log("I like these colours" + " " + colours[i]);
};

#3

while(compliment)
that's OK


#4

Thank you for your help.