alert("hello javascript!")


If HTML is like the bones, and CSS is like the skin, Javascript is like the muscles and nervous system. It makes your webpages smart and able to do things that interact with people.

Things like:

  • changing how things look on a page without reloading it
  • remembering visitor's name, email, and profile picture
  • making things happen when you click buttons

Here's a simple example that shows an alert when you click a button:

<button onclick='alert("Hey there!")'>Greet me!</button>

Make sure to use different quotes around the onclick attribute vs. the quotes around the text argument in the alert method.

Challenge

Make a treasure hunt game with buttons that alert you when you found the treasure.


Solutions

Try this challenge on your own first, then come back here to see other people's solutions.

Try this challenge on your own first, then come back here to see other people's solutions.