I am new to Javascript programming and this is also my first post on a forum so I hope I am using the right etiquette here!

Please could somebody offer me some advice on how to sum the numbers from one to ?? as part of a 'for' loop? What I need for example is a program that adds the collective numbers 1+2+3+4+5 (etc) and outputs the total of 15. I have attached the file as I have written it so far.

Thank you for replying to this query, I really appreciate it. I do need to write it as a 'for' loop as you have shown in your replacement code for me, although I have run the program again with the new code and I am still getting the message 'the sum of 1 to 5 is NaN', is it something to do with the way sum has been valued?