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.

Write JavaScript code using a do-while loop to generate a sequence of numbers from 1 to 5. The loop should execute at least once, regardless of the initial condition. Also, calculate the sum of these numbers within the loop and display the final sum after the loop completes.

2.

Explain the difference between the setTimeout() and setInterval() functions in JavaScript. Provide a practical example demonstrating the use of each function and clearly state the intended outcome of each.

3.

Question 2: Describe the difference between inline, internal, and external JavaScript. Discuss the advantages and disadvantages of each approach, considering factors such as code organisation, maintainability, and browser performance.