I was working through a code challenge and struggling. When I viewed the solution I noticed the following:
(I’ve simplified the problem below as the full challenge is long.)
let num = -10; console.log(-num); // Will log positive 10 to the console.)
Why does the above log 10 to console. What is the code actually doing behind the hood. Does it look like this when being worked out:
If so, why does --10 = positive 10?
I think this is fairly simple maths and feel silly as I can’t wrap my head around it.