Which looping statement is suitable when the number of iterations is not known beforehand?
- for loop
- while loop
- do...while loop
- forEach loop
A while loop is suitable when the number of iterations is not known beforehand. It allows you to repeat a block of code as long as a specified condition is true. This makes it a flexible choice for situations where the loop's exit condition isn't predetermined.
Loading...
Related Quiz
- The method myArray.find(callback) returns _______ if no element passes the test.
- If you want to convert a JavaScript object to a string in the Fetch API, you should use the _________ method.
- Question 1: You are developing a web application and notice that when user-generated content is displayed on the page, it interprets HTML and JavaScript code. How can you prevent this behavior and enhance security?
- Which of the following options is a technique to manage callback hell in JavaScript?
- You're building a weather application and you're using the Fetch API to request weather data from a third-party API. However, you realize that the application does not properly handle when the API is down. How would you handle this to inform the user?