Ruta’s Savings Jar
JavaScript
20 pts
Ruta’s Savings Jar
Ruta has let money = 120; Nakfa in her savings jar. Change money with a shortcut operator at every step and print it with a label:
- She earns 30 Nakfa (
+=) → printAfter work: … - She pays 45 Nakfa for the bus (
-=) → printAfter the bus: … - Her uncle doubles her money (
*=) → printDoubled: … - She gives half to her brother (
/=) → printHer half: … - She buys as many 20-Nakfa notebooks as she can; keep only the leftover (
%=) → printLeftover: …
Expected output:
After work: 150 After the bus: 105 Doubled: 210 Her half: 105 Leftover: 5
Do not type 150, 105 or 210 in your code.
Checklist
- Use
+=and-=for work and the bus. - Use
*=and/=for doubling and halving. - Keep the leftover with
%=; no typed results. - Print all five labelled lines.
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
