Question 1
7 marksEvaluate OCR 3^4, 23 DIV 5 and 23 MOD 5 and translate them into JavaScript. Give JavaScript equivalents of int("8"), float("1.5") and str(8), with resulting values/types. Explain why copying ^ is wrong.
Show solution and marking guidance
Indicative answer
- 1 mark: 81; JavaScript 3**4.
- 1 mark: quotient 4; Math.floor(23/5).
- 1 mark: remainder 3; 23%5.
- 1 mark: Number("8") gives numeric 8.
- 1 mark: Number("1.5") gives numeric 1.5.
- 1 mark: String(8) gives string "8".
- 1 mark: JavaScript ^ is XOR, so 3^4 is 7 rather than 81.