I’m confused about JavaScript | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I’m confused about JavaScript

I’ve just started learning JavaScript but I’m confused. It says that you need to use the script tags for JavaScript. But in all of the SoloLearn examples there are no script tags in the HTML section. It just has code written in the JavaScript section of the coding playground.

25th Jan 2020, 3:56 AM
Gunner Beal
Gunner Beal - avatar
6 Answers
+ 2
//The JavaScript codes you write in JavaScript section get render in html section for eg: JavaScript section console.log("Hello world"); Rendered code in html //html codes <script> console.log("Hello world"); //Its fine you write in HTML or JavaScript section at final JavaScript get render in HTML, but writing in JavaScript section makes code not confusing and clean
25th Jan 2020, 4:01 AM
Sudarshan Rai
Sudarshan Rai - avatar
+ 2
Yes, you can say that.
25th Jan 2020, 11:49 PM
🇮🇳Vivek🇮🇳
🇮🇳Vivek🇮🇳 - avatar
+ 2
Learn Javascript give you a colossal power. You need a little of html and css, and with lot of practice yo can start the angular or react way and be a mr. frontend. script tags exist to call the js code into the html document. js is the power.
26th Jan 2020, 9:06 AM
Gino Pietrobon
Gino Pietrobon - avatar
+ 1
SoloLearn playground is different from actual text-editor. In sololearn you did not need link to javascript. Here, it is already linked. But on our local machine. HTML files need script tag. Script tag also works on sololearn playground if you do not want extra file for your javascript you just do this <script> console.log("hello "); //your javascript code here... </script> You can write script tag either in head tag. Or you can also write your script tag before closing or ending body tag. But, What when we want to add external files to our HTML? Well, here is solution, you can do this <script src="your javascript file path"> </script> For Example. I have javascript file in folder js and my file name is main.js. I can do this <script src="js/main.js"> </script>
25th Jan 2020, 4:31 AM
🇮🇳Vivek🇮🇳
🇮🇳Vivek🇮🇳 - avatar
+ 1
Here you can see I have done my all javascript code with in HTML file. https://code.sololearn.com/WS1r9gvQ2Jnm/?ref=app
25th Jan 2020, 4:34 AM
🇮🇳Vivek🇮🇳
🇮🇳Vivek🇮🇳 - avatar
0
So basically the script tags are to link an external javascript or CSS page to your HTML?
25th Jan 2020, 6:22 PM
Gunner Beal
Gunner Beal - avatar