<script> document.write("<h1>Hello world!!!</h1>"); </script>
<script> x = 3; x = 7; result = x + x; document.write(result); </script>
The first value of variable x is overridden by the second one because both variables are treated as one and in programming the value defined at the last overrides the first one.
<script> x = 3; X = 7; result = x + X; document.write(result); </script>
Both variables are recognized as separate entities here. So, the output is the desired one.