const todolist= []; let todolisthtml = ''; for(let i =0;i`${todo}`; todolisthtml += html; }
Here, whenever we iterate through the loop, we are reassigning the variable todo, which should cause an error because we declared it using "const", but it works smoothly
This is not a task. Just declaration and initialization.
If you write
This would be a reallocation and is illegal.
In what you wrote,
todoandhtmlgo out of scope at the end of the loop block, followed by a newtodoandhtmlis created for the next iteration.As Jaromanda X said,
constvariables are block scoped. Andlet.