DS - while loop
The article discusses the use of while loops in programming to simplify repetitive tasks. It provides examples of how to print a specific value multiple times without writing extensive code. The author explains the structure of a while loop and demonstrates its application in various scenarios.
- ▪While loops allow for repeated tasks to be executed with fewer lines of code.
- ▪The article provides examples of printing a value multiple times using a while loop.
- ▪It explains how to modify print statements to format output as desired.
Opening excerpt (first ~120 words) tap to expand
try { if(localStorage) { let currentUser = localStorage.getItem('current_user'); if (currentUser) { currentUser = JSON.parse(currentUser); if (currentUser.id === 3867633) { document.getElementById('article-show-container').classList.add('current-user-is-article-author'); } } } } catch (e) { console.error(e); } AravindhBalakrishnan Posted on May 26 DS - while loop #dsa Let's discuss about while loop. We need to print a particular value say 5 for 10 times. print(5) print(5) print(5) print(5) print(5) print(5) print(5) print(5) print(5) print(5) Output : 5 5 5 5 5 5 5 5 5 5 Enter fullscreen mode Exit fullscreen mode writing the above code give the expected output as expected, but if we need to print the same for 10000 times or 1000000 times we can write that many lines which will take more…
Excerpt limited to ~120 words for fair-use compliance. The full article is at DEV.to (Top).