Back To Lesson

Quiz: Introduction to Javascript

Quiz Instructions:

  • Each question is followed by multiple-choice answers (A, B, C, D, and sometimes E).
  • Carefully read each question and all answer options before selecting the best answer.
  • Choose the option that most accurately aligns with the key concepts or information provided.

Question 1: What is the primary purpose of JavaScript in web development?

Question 2: How can JavaScript be added to an HTML file?

Question 3: Why is external JavaScript preferred for larger projects?

Question 4: What does the following code do?

console.log("Hello, World!");

Question 5: What is the purpose of the DOMContentLoaded event in JavaScript?

Question 6: What happens if the <script> tag is placed at the end of the <body>?

Question 7: What does the following code snippet do?

<button onclick="alert('Hello!')">Click Me</button>

Question 8: Which JavaScript method updates an element's text content dynamically?

Question 9: What is a common use of JavaScript in forms?

Question 10: How can you test JavaScript without adding it to an HTML file?

Question 11: Which JavaScript feature allows interaction with user events like button clicks?

Question 12: What does the following HTML/JavaScript code achieve?

<h1 id="header">Hello!</h1>
<script>
document.getElementById("header").innerText = "Welcome!";
</script>

Question 13: What is the best practice for managing JavaScript in large projects?