This output is indeed not very helpful. I guess they create a "properly formatted" version of the script and apply a generic diff tool (you can learn more about those later in the course, in the "similarities/more" problem). Easy solutions coming to my mind would cause serious limitations.
It's usually considered good style to add a single space on both sides of a binary operator (operators with two operands, like *
, %
, +
, ==
, <
, &&
, =
, and a few more, while for example !
negation operator is an unary operator and grouped with its only operand). I assume if you add those spaces, the diff will work better.
With a more reasonable output, you'd usually remove what is red and replace it with what is green.
As a dirty trick, you could add lines with unique garbage in between as comments, like
code line 1
// totallygarbageweuris-mnasdfjoiwert9w0etlsa
code line 2
// moregarbagelkfiasdf39j234calljenny867-5309
code line 3
The garbage line would be same in the compared code versions, likely preventing it from mixing the lines. Remove the bogus comments before submitting, and don't forget adding reasonable comments, so another person reading the code might better understand it. Another person might be you next month.