Originally Posted by beatc
Is there something wrong with my code? The output produced is not the same as i expected. Please help. Thank you.
Yes, there is something wrong with the code. What output did you expect? Have you tried using your error console? Have you tried inserting alerts at strategic positions to inpect the values of variables?
So document.write() is at best really only useful to write the original content of your page.
Hint: create a global variable named result = ""
, then at each step use result += whatever
. Use result += "<br>" to create the line breaks. Then at the end invoke document.write once
to display the result.
We wil not do your homework for you, but I hope this has given you a push forward.
"It ain't what you don't know that gets you into trouble. It's what you know for sure that just ain't so." - Mark Twain, US humorist, novelist, short story author, & wit (1835 - 1910)