Javascrpt script tag doubt

The shown program above gives error as we remove the script tag from body and write in head.why is it so that just by changing the location an error occured ?

No it will not give an error ,i have done that part by using script tag in head as well as in body tag html
content.U should check your program to find out where it is showing error.

Can u please send a “screenshot” of the code you have made changes ?
That way i may be able to clear your doubts easily…
because i changed the location of the script tag…it doesnt show any errors