• +1 240 877 8161
  • info@thePracticalIT.com
Practical Information Technology
  • Notifi
  • Canvas
    • HOME
    • Start Here
    • Courses
    • EVENTS
      • EVENTS LIST
      • EVENTS GRID
    • BLOG
    • CONTACT
    • IT Courses
  • +1 240 877 8161
  • info@thePracticalIT.com
  • Profile
  • Login | Registration Popup Link
Practical Information Technology
  • Home
  • Courses
    • FEATURED COURSES
      • Web Development
      • Database Development
      • Business Intelligence
    • TRAINING
      • How long does it take?
      • IT Training Methods
      • Hours Per week
      • Payments
    • IT Courses
  • Tips
  • Contact
  • Notifi
  • Start Here

Convert For Loop to While loop

Homepage - Programming Exercises - Convert For Loop to While loop

Pract IT

by Practical IT
Posted on 23 May, 2021
in
Programming Exercises
1 Comment

Given the following for loop statement, convert it to while counterpart.

let total = 0;
for (let i=1 ; i < 20 ; i++) {
    total = total + i;
}
console.log("The total is " + total);

What is expected

By going through this exercise, you will understand how similar for and while are as far the task is concerned. So the while, at the end, shall work just like the way for works as far as the result is concerned.

Hint: On the case of for loop, the counter is handled by the for construct itself. On the case of the while, the programmer needs to track that.

Tags: daily exercise javascript logics problems programming quiz starter
User Avatar
Article by Practical IT

Works at Practical IT. Passionate about Technologies, Business and News.

Previous Story
Full Stack – explaining it to granny
Next Story
Counting Numbers Above 20

Related Articles

May 2025 IT Class Application

[wpforms id="3116"]

Your Path to a Lucrative IT Career Starts Here – Enroll Now!

Ready to Unlock a High-Paying Career in Tech? Claim Your...

Leave your comment Cancel Reply

(will not be shared)

SearchLeave your keyword

Change your life through Information Technology career today. Thousands have done it – it is your turn now. All you need is a passion to change your life and provide better for yourself and your family. Practical IT takes the rest.

QUICK LINKS

  • Home
  • Courses
    • FEATURED COURSES
      • Web Development
      • Database Development
      • Business Intelligence
    • TRAINING
      • How long does it take?
      • IT Training Methods
      • Hours Per week
      • Payments
    • IT Courses
  • Tips
  • Contact
  • Notifi
  • Start Here

SUBSCRIBE EMAIL

Subscribe to our email list and get tips on IT jobs, career changes openings, seminars and more. We can also SMS you

GET IN TOUCH

You can call us, email us or even better visit us in our office at the heart of Silver Spring. Our Email - info@thePracticalIT.com

+1 240 877 8161

911 Silver Spring Ave #101 Silver Spring MD 20910

Practical IT - Copyright 2023.
  • Sign in

or
  • Login with Facebook
  • Login with Google

Forgot your password?

Lost your password? Please enter your email address. You will receive mail with link to set new password.

Back to login