Jump to content

I am not understanding JS Try It Yourself


shower
 Share

Recommended Posts

I don't understand how you can learn JS with Try It Yourself

I finish the HTML and can understand better because I can go to public sites and view source code and see how it's planted in and used for each element.

I can't do that with JS since it's hidden in server. 

For example

let x, y, z;  // Statement 1
x = 5;        // Statement 2
y = 6;        // Statement 3
z = x + y;    // Statement 4

and than Try It Yourself would produced this output

A JavaScript program is a list of statements to be executed by a computer.

The value of z is 11

I understand how it got the calculation but have no clue how I would use this in a real scripted website. The whole JS Tutorial is small pieces like this and I am not sure if I am doing this right by just reading and trying it with editor with no context. I assume these statements etc will turn into blinking rotating images, games and interactivity somewhere later. Does anyone have any suggestions how I could learn from Try it Yourself ? Where can I see full JS codes used in website online so I can compare with the Try It Yourself code I practice on this site ? thank you in advance

Link to comment
Share on other sites

Javascript is not a server-side language. It's available to you in the browser, so none of the code is hidden. Javascript code is usually very complex, so you might not understand it when you look at a website's source code, but it is there. Often, websites will load Javascript from a separate js file using a <script src="..."> tag, you can see the Javascript code in that file.

Here's the example you're talking about: https://www.w3schools.com/js/tryit.asp?filename=tryjs_statements  All of the code in that example is visible.

The tutorial pages themselves don't show all of the code, just the parts that they're talking about because it would be hard to highlight the part of the code they want you to focus on if the entire program was there. You can always click the green "Try it Yourself" button to see the missing code.

Even those these small pieces of code seem useless, they are the basics. You need to learn them because the more advanced tutorials won't make any sense without this knowledge. The part of the tutorial that tells you how to modify things on the page is in the HTML DOM section but you need to know all of the basics like variables, functions and object before you can understand how to use the HTML DOM.

If you would like to see real world applications and try to understand them for yourself, W3Schools has a whole series of examples in their How To section.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...