21 Programming for the web (3)

Resources | Revision Questions | Information Technology IT

Login to see all questions

Click on a question to view the answer

1.

Question 3: Explain the purpose of the DOM (Document Object Model) in JavaScript. Provide an example of how JavaScript can be used to modify the DOM to change the content of an HTML page. Include the relevant JavaScript code.

2.

Describe the potential problems that can arise when using setInterval() and outline two different methods a developer can use to prevent these problems. Explain how each method works.

3.

Question 3: Write a JavaScript function that takes an array of numbers as input and returns a new array containing only the even numbers from the input array. The function should use a for...of loop. Include a brief explanation of the function's functionality.