Trace the Variables

The trace table

To trace a program, keep a table with a column for each variable. Read one line, work out its right side with the values the table holds at that moment, and write the result in that variable's column. The old value is gone, and a later line can't reach it.
Linegm
let g = 9;9
let m = 2;92
g = g * m % 5;18 % 5 is 32
m -= g ** 2;32 - 9 is -7
g += Math.floor(m / 2);3 + (-4) is -1-7
It prints -1 -7. The fourth line squares the new g, which is 3 by then. On the last line m / 2 is -3.5, and Math.floor goes down the number line to -4. Math.trunc would have stopped at -3 and left g at 0, so the two functions give different traces once a negative division leaves a fraction.

Text values in the table

Write a text value with its quotes, because the next plus sign depends on it. A plus sign with text on either side joins. It works left to right, so once a piece of text has been joined the result stays text. A minus sign or a star has only one job, and it turns text into a number.