Skip to main contentSkip to solution

What is the purpose of JavaScript in a website?

Solution

✅ Correct Option: 2

JavaScript is a scripting language that runs in the browser and responds to user actions such as clicks, form input and scrolling. It updates page content without reloading, validates forms, and handles animations and other behaviour, which makes a website interactive and dynamic.


Option 3: structure is provided by HTML, not JavaScript.

Option 4: styling (colours, fonts, layout) is done by CSS.

Option 1: data storage is mainly handled by databases on the server side, not the main purpose of JavaScript.

Memory trick: HTML is the skeleton, CSS is the appearance, JavaScript is the behaviour.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question