+ 2

is this tag neccessary.. before writing javascript program

<script type="text/javascript">

7th Jan 2019, 5:26 AM
Wasiq Abdullah
3 odpowiedzi
+ 2
The tag of script is necessary to indicate that the enclosed scripts are JavaScript. In Sololearn code playground, you feel like you don't need this, but actually the codes in JS tab all are put inside <script></script> and placed into HTML when you run the code. Further information, they are put before </head>, if you need to get DOM elements, put your scripts In window.onload = function(){ .... }
7th Jan 2019, 10:54 AM
Gordon
Gordon - avatar
+ 3
thanks
7th Jan 2019, 1:04 PM
Wasiq Abdullah
+ 1
You can remove the type attribute
7th Jan 2019, 5:34 AM
Calviղ
Calviղ - avatar