Hello All,
I’m doing the team-stats exercise:
When writing the addPlayer method, I accidentally omitted the ‘const’/‘let’ keyword before ‘player =’, so I wrote this:
addPlayer(firstName, lastName, age) {
player = {
firstName,
lastName,
age
}
team.players.push(player);
}
Much to my surprise this generates no error and the player gets added to the team. Why can I leave ‘let’ / ‘const’ out in this situation? The editor doesn’t pick it up correctly because the colouring is not correct (everything stays orange iso turning into cyan), but apparently the player object gets created.
Thanks!