The code element does not preserve whitespace and line-breaks.
To fix this, you can put the code element inside a pre element:
var x = 5; var y = 6; document.getElementById("demo").innerHTML = x + y;