coglabuzh / online-exps

Unleash the full potential of JavaScript and supercharge your web experiments with this library for experimental programming - based on jsPsych - work in progress! 🎯
2 stars 0 forks source link

Math equation generator #19

Open chenyu-psy opened 8 months ago

chenyu-psy commented 8 months ago

Hi Ajit,

I hope there could be a function that can generate math equations. There are several requirements for the math equation:

  1. maxNum: The maximum number in the equation. All numbers in the equation should be smaller than that number. Usually, the value is 10 or 20.
  2. nOperation: The number of operations in the equation. For example, an equation with two operations could be "3 * (4 + 1)". The input number will only be 1 or 2.
  3. diff: The difficulty of the equation. By default, only addition and subtraction operations are involved. For the difficult condition, multiplication and division will be involved as well. If there are two operations in the equation, one of them must be addition or subtraction.
  4. answer: true or false. If it is true, the answer will be displayed; if false, the answer will be hidden.
  5. correct: true or false. Return a correct answer or a wrong answer.
  6. The return should be an array or an object that includes the equation, the displayed answer, and the correct answer.

Here are some example of the equations: 3 + 2 * 5 = ?; 8 - (5 - 2) = 5; 4 + 12 = 14; 6 + 8 / 4 = 4

chenyu-psy commented 8 months ago

@GidonFrischkorn Do you have something else want to add?

ajit283 commented 8 months ago

Hi, I have created a first version of the equation generator, you can find it in the basic-fun folder