DEV Community

SILAMBARASAN A
SILAMBARASAN A

Posted on

Why is loop?

same code repeated times
same work multiple times

Without loop print 1 to 10

Without loop
print(1)
print(2)
print(3)
print(4)
print(5)
print(6)
print(7)
print(8)
print(9)
print(10)

With loop

let i = 1;
while(i<=10){
print(i)
i++
}

Top comments (1)

Collapse
 
payilagam_135383b867ea296 profile image
Payilagam

Please explain them line by line.