0% found this document useful (0 votes)
3 views2 pages

JavaScript Loops

The document covers basic JavaScript concepts including loops, specifically the for loop syntax and its components. It also explains the toLowerCase() method for converting strings to lowercase and the modulo operator for finding remainders in integer division. Additionally, it describes the use of the break statement to exit loops.

Uploaded by

nidhiagarwal2k
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

JavaScript Loops

The document covers basic JavaScript concepts including loops, specifically the for loop syntax and its components. It also explains the toLowerCase() method for converting strings to lowercase and the modulo operator for finding remainders in integer division. Additionally, it describes the use of the break statement to exit loops.

Uploaded by

nidhiagarwal2k
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

JavaScript Loops

Loops are among the most basic and powerful of programming


concepts.
A loop statement allows us to execute a statement or group of statements
multiple times.

JavaScript For Loop


The for loop has the following syntax:
for (statement 1; statement 2; statement 3) {
// code block to be executed
}

Statement 1(initialization)- is executed (one time) before the execution of


the code block.

Statement 2(condition) defines the condition for executing the code block.

Statement 3(updation) is executed (every time) after the code block has
been executed.

Example
for (i = 0; i < 5; i++) {
text += "The number is " + i;
}
JavaScript
String toLowerCase() Method
The toLowerCase() method converts a string to
lowercase letters.
Example
Convert the string to lowercase letters:

var str = "Hello World!";


var res = [Link]();

Output: hello world!

Modulo Operator (%) in Javascript


The modulo operator, denoted by %, is an arithmetic
operator.
The modulo division operator produces the remainder of an
integer division.
Example - 20%5 = 0
21%6 = 3

What is the use of break statement ?

The break statement is used to "jumps out" of a loop.

You might also like