Uncaught TypeError: Assignment to constant variable

Hi everyone

this is my work


this is my code:

I don’t understand the error can I get some explication ?
thanks

cursor.x=event.ClientX/sizes.width

1 Like

From Program Structure :: Eloquent JavaScript

The word const stands for constant . It defines a constant binding, which points at the same value for as long as it lives.

Instead of const cursor use let cursor or (as I think you probably intended) modify cursor.x and not the variable itself:

cursor.x = event.clientX / sizes.width;
3 Likes

thanks guys

2 Likes