Free chats with grandmas
First, paste the function into the console and then call the function by passing in a string: You could also call the same function by passing in a variable that points to a string (in the above example we just typed the string straight in there as a value instead of saving it to a variable first): The line on the other hand doesn't belong to anyone so it would be technically incorrect to refer to it as a method (confusing, I know).
The last line of the function is another built-in that simply takes in any values that you give it and prints them out into the console.
First, right click anywhere on the screen and hit Inspect Element, then click on the Console tab.
You should see a thingy that looks like this: This is a console, otherwise known as a "command line" or "terminal".
Basically it's a way to type one thing at a time into a computer and immediately get the computers answer back.
They are super useful as a learning tool (I still use the console nearly every day that I'm coding). Here I have started to type something and the console is helping me out by giving me a list of all the possible things I could continue to type!
You might be wondering what other functions are available in Java Script. There are lots built in, standard libraries that you can learn about at MDN (A site run by Mozilla that has lotsa nifty information about web technologies).
For example here is the MDN page on Java Script's Math object.
Java Script started as a way to make web pages more interactive.Another thing you could do is type key and watch what happens.Using the console is a very important part of learning Java Script.First go to the Underscore site, click on the download link (I usually use development versions because they are easier to read but both will give you the same basic functionality), and then copy all the code onto your clipboard (you can use Select All from the Edit menu to select everything). Here is how we would write this in the console manually if we weren't using a function: The expression ).Let's use our function instead of doing it manually.
If I were to hit the Refresh button in Chrome, for example, my variable would get wiped and it would be like it never existed.