Difference between let and var
The difference between let and var is in the scope of the variables they create: Variables declared by let are only available inside the block where they’re defined. Variables declared by var are available throughout the function in which they’re declared.
REF: https://sentry.io/answers/difference-between-let-and-var-in-javascript/#:~:text=The%20difference%20between%20let%20and,in%20which%20they’re%20declared.