Currently taking a course in treehouse on javascript. I understand when the instructor changes the value of a variable with just the = sign. But sometimes the instructor uses += and never really explained why. Im having a hard time understanding the difference between the two signs and on what instance would I use either of them. I would like your input on it to help me better understand, thank you. ie :
var message = "hello";
message = "Whats up";
console.log(message); //Will log: Whats up
var anotherMessage = "Hey";
anotherMessage += "How are you doing?"
console.log(anotherMessage) //What would happen here, and why?
Aucun commentaire:
Enregistrer un commentaire