Skip to main content

Posts

Showing posts with the label built-in methods

JavaScript Basic: Three Useful Built-In Methods To Act Your Site

In the last post, I shared five primitive data types. Even though I could write some basic variables and do some math in the console, I don't see any action from the website.  How to let website take action? We will need to know three built-in methods: Alert It pops up a message to the user, and it alerts the user. Console.log What console.log will do is print something to the JavaScript console. Prompt Prompt is very useful for us because it lets us get input from a user. The second part of prompt is that we can store it in a variable. Now I am going to apply those three built-in methods in HTML, so you can see how they work. Firstly, I create a simple HTML page, and I only add the title. Then I add a <script> tag and link to a separate file named "script.js". I want my site to pop up a message when you open it. In the "script. js" file, I name my variable as "userName", and it equal to prompt("What is ...