Const has to be defined?

Shows an error whenever I don’t define the const variable.

Yup. That is to be expected. Once you bind a value to a variable using const, you can’t reassign to that variable.

If you want to reassign the value, use let instead.


I think said error isn’t caused by an attempted reassignment though, but by the variables not having assigned an initial value – which would indeed make const declarations rather pointless here.

Sorry, that was what I meant. There is no point in declaring them without an initial value (and indeed it is not possible), as you won’t be able to reassign them.

1 Like

The normal process is to start off by using const to assign the variable. That way you are warned about reassignments, as you have been.

Frequently there are solutions that can be put into place that result in the reassignment no longer needing to occur.

1 Like

Just as a heads up you are going to run into an issue with this function

function setNextQuestion() {

shuffledQuestions is an array[index] not a functionToCall(argument).

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.