JavaScript Introduction

What JavaScript can do.

✍️ 3 exercises + code challenge in this lesson

JavaScript is the programming language of the web. Together with HTML (structure) and CSS (style), it adds behaviour to web pages.

JavaScript can…

  • Change HTML content and attributes.
  • Change CSS styles.
  • Show or hide elements.
  • React to clicks, typing and other events.
  • Load data from servers without reloading the page.

JavaScript also runs outside the browser, on servers (Node.js) and in mobile and desktop apps.

Key Takeaways: JavaScript Introduction

Mastering JavaScript Introduction helps you write clean and reliable JavaScript code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

JavaScript Introduction Code Example

JavaScript
<h2 id="demo">JavaScript can change this text.</h2>
<img id="bulb" src="https://picsum.photos/id/1/120/80" alt="Picture" width="120" height="80">
<br>
<button onclick="document.getElementById('demo').innerHTML = 'Hello JavaScript!'">Change text</button>
<button onclick="document.getElementById('demo').style.color = '#2563EB'">Change colour</button>
<button onclick="document.getElementById('bulb').style.display = 'none'">Hide image</button>
Free sign-in required · Google login available

JavaScript Introduction Practice Exercises

Check what you learned in “JavaScript Introduction”.

/ 3 solved
Fill in the blank

Change the content of the element with id "demo".

document.getElementById("demo"). = "Hello";
✓ Correct! Not quite. Try again.
Multiple choice

JavaScript is mainly used to…

✓ Correct! Not quite. Try again.
Code challenge

Change the text of the <h2> to "Hello JavaScript!".

Write the code in the live editor. Your answer is checked automatically.

Free sign-in required · Google login available

to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services