NOTE: The indents get messed up in html. Use your bracket matching skills like you use in read code. Remember the if does not need brackets if just one statement either done or skipped.
document.write(“needs work” +<br>”);
sum = sum + nums[i];