Alea in questions

Hello i want to make questions with alea numbers like this :slight_smile:

RECTO : Tom have 5 ball. He lost 3 balls. How many balls have he ?
VERSO : 5 - 3 = 2. He have 2 balls.

How can i create a card where the numbers are randomize ?
I want the 5 and the 3 randomize and the 2 must be calculing.

Is it possible ?

Thanks in advance

Use javascript in your card template

Yes, but how ?
I’ve search a lot and i don’t find.

Thanks in advance

I don’t use anki anymore and I don’t really know javascript but this should help, I just googled
anki javascript random number

This is not as straightforward as the post @4649ceynou linked to, because that snippet of code makes a lot of assumptions about you card template, and will break easily. Instead, I would recommend reading this, as it contains the same question, with a step-by-step solution that you should be able to follow even if you know nothing about javascript.

However, that post also contains some words of warning about randomization in showing content. In your case, the issue with what you are trying to do is: Anki is made to memorise content, not to learn content. This means that modifying the content shown each time you review it by thinking this way you’re going to learn, say, subtraction, and not memorise just one particular subtraction result (say, 5-3), will by essence bypass assumption Anki makes about the content of your card because you are no longer trying to memorise, but to learn.