JavaScript is an easy yet powerful programming language used by web developers. This can be used to animate pages, change page elements, and even program browser based games. There are so many different things you can do with it that it would be beyond the scope of this page to do everything so lets dive into the basics.

When programming in JavaScript you need to ensure that the script is in the applicable <script></script> tags so the browser knows that it is JavaScript and doesn't try to display it as HTML.

You can place as many JavaScript functions as you want inside of your web page, and they can be in both the <head> tags or the <body> tags. If you would like to define all of your functions in your <head> tag and then call them in the <body> that works, or even vice versa. It is important however that you place them in a way that is easy to read and change, especially if you are not going to be the only one working on it. You should come up with a best practices method for your group and stick to it.

If you would like to send an alert to the page you can do it just by simply doing the below:

<script>
alert("I am an alert!")
</script>

Or you could define it as a function:

<script>
function sendAlert(){
alert("I am an alert!")
}
</script>

And then call it later or on a button press:

<button type="button" onclick="sendAlert()">Click me for an alert!</button>

Another fun thing that you can do with this is you can change the data on the webpage itself. You can add, remove, edit, and calculate data on the page. You can even write the page itself through JavaScript, which unless it is a very small page it is not feasibly, through the document.write() function. You just put whatever you want to be written to the page in the parenthesis and there you go. Just remember that this method, if not at a later time, will delete everything on the page.

You can also use a different method to change all items on a page by their id. This is done by the document.getElementById() and running the .innerHTML method. It would be done like this:

<div id="changeme"></div>

<script>
document.getElementById("changeme").innerHTML = "I now have something written here :-D";
</script>

These are very simple functions, what happens if you want to do something more complicated? Well that is all up to you! You can do almost anything here, even a Sudoku generator or solver for a webpage. This would be very complicated so you may even want to store the code in a separate file so you don't flood the webpage with crazy code and forget that there is a webpage you are building this on.