Custom algorithm for answer's validation and data-sharing between front and back of a card

For the sake of completeness, I think sessionStorage method should also be mentioned explicitly. It is much simpler than the reddit post might imply. Just use

sessionStorage.setItem("a", a);

to save data and

sessionStorage.getItem("a");

to retrieve it. Wrap it in Number() for numeric values or in JSON.parse() for general kind of objects.


The anki persistence script basically does that exact thing, just making some utility functions built on top of the sessionStorage. Although, in many cases it might be more convenient to use the latter directly.


Regarding defining variables in the global scope, it should be noted that it probably won’t work on AnkiMobile. On AnkiDroid, the old study screen, to my knowledge, does not have all the functionality of the old one yet. And as for the desktop, at some point dae mentioned that

which might mean that global variables are not be the most future-proof method in general. (Although, who knows how those plans were affected by the current state of things).