js/qa-generator.js
// Do a random operation on equation
Do a random operation on equation
Do a random operation on equation
function randomOperation(operations, expr, maxValue) {
      var operation = operations[Math.floor(Math.random() * operations.length)];
      var number = 0;
      number = 3 + randomNum(maxValue);
      switch (operation) {
        case "/":
          if (number > 0) {
            expr = expr.divide(number);
          }
          break;
        case "*":
          expr = expr.multiply(number);
          break;
        case "+":
          expr = expr.add(number);
          break;
        case "-":
          expr = expr.subtract(number);
          break;
      }
      return expr;
    }
function randomOperation ( operations , expr , maxValue ) { var operation = operations [ Math . floor ( Math . random ( ) * operations . length ) ] ; var number = 0 ; number = 3 + randomNum ( maxValue ) ; switch ( operation ) { case "/" : if ( number > 0 ) { expr = expr . divide ( number ) ; } break ; case "*" : expr = expr . multiply ( number ) ; break ; case "+" : expr = expr . add ( number ) ; break ; case "-" : expr = expr . subtract ( number ) ; break ; } return expr ; }
Do a random operation on equation
Do a random operation on equation
// get a random operation