y = x + x + x
instead of
y = x * 3
The real author the assignment clearly knew that for the particular machine it was executing on that 3 addition ops were faster than a multiply and couldn't help themselves.
When questioned as to why this was, the student couldn't explain the meaning of the expression and the jig was up
For JavaScript, you get all sorts of additional complications depending on how good your JIT is. For example, you have to check both integer addition and integer multiplication for overflow (at which point you have to recompile as doubles) unless your interval analysis is good enough. So the cost is more than just the cost of the machine add in some cases.
In practice, I'd be suprised if current JS JITs do strength-reduction in this case. They might get there sometime in the next few years, but there's lower-hanging fruit to be had so far.
If you're trying to make sure that your compile times are also short, it might not be worth it.... yet.
but yes, i agree with you that for an intro class, students should focus on writing clear code and then optimizing for performance later.
Two more lines worth it.