The <script>
will be executed every time, you go to the next card, but in the same context.
If you use a let
assignment with the same identifier (quoteanswer
in this case) multiple times, JavaScript will complain, that "quoteanswer
has already been defined".
However, with var
, you’re allowed to redefine the variable.
TLDR, because this is valid JS:
var a = 5;
var a = 10; // OK: a is now 10
but this is not:
let a = 5;
let a = 10; // ERROR: a has already been defined