error in this line
document.writeIn( "<h1>The sum is " + sum + "</h1>");

it is writeln i.e "L" and not "I"
writeln means "write line"

make the change,and it will work perfectly.