Iteration with "Do" in loops

I understand what information is given in the challenge, a do is used in the places where we want to ensure that the function runs atleast once, the only problem I have is, I cannot imagine any case where it’s the case. Of Course, do forgive me since I am not yet experienced in programming. However, I fail to understand what such situations will arise.

Hi, @Brijesh

Could you share a link to the challenge, please?

Learn Basic JavaScript: Iterate with JavaScript Do…While Loops | freeCodeCamp.org

The do…while loop is just one way of iterating through the collection of items. In some cases, it might be useful, for example, when you want to stop looping at the first match.

Honestly, after several years with JS, I don’t use the do…while loop method at all because it can trigger an infinite loop if the condition won’t be met. Why bothering to learn it then? - it is crucial to know that this method and approach exists :slight_smile:

1 Like

Thanks a ton!!! I’ll keep it in mind.

1 Like