CSD 360 - JS Calculation

Mod 4 Assignment

Starting with the following JavaScript:

  1. var i = 842;
  2. document.write(i + i % 3 / 7 - 2 + 7 ** 3);

Using parentheses to modify the output line to alter the result of 1183.2857142857142 to the following list of outputs.

  • 341.14285714285717
  • 1185.4
  • 842.0011574074074
  • 113.28571428571433
  • 343.2
  • 841.75

Solutions
Expected Output Expression
1183.2857142857142
  • (i + i % 3 / 7 - 2 + 7 ** 3)
  • =
341.14285714285717
  • ((i + i) % 3 / 7 - 2 + 7 ** 3)
1185.4
  • (i + i % 3 / (7 - 2) + 7 ** 3)
842.0011574074074
  • (i + i % 3 / (7 - 2 + 7) ** 3)
113.28571428571433
  • (i + i % 3 / 7 - (2 + 7) ** 3)
343.2
  • ((i + i) % 3 / (7 - 2) + 7 ** 3)
841.75
  • (i + i % 3 / (7 - (2 + 7)) ** 3)