Conditional Rendering in React Complete Guide with Examples 2026

Image
  Conditional Rendering in React Conditional Rendering is one of the most useful concepts in React. It means showing different content on the screen depending on a condition. For example: If a user is logged in → show Logout If a user is not logged in → show Login If a student has passed → show Congratulations If a product is available → show Buy Now If data is loading → show Loading... React does not have a separate if rendering tag. Instead, we use normal JavaScript conditions such as if, the ternary operator, &&, and switch to decide what should appear in the UI.

javaScript do while loop

javaScript do while loop



        

 JavaScript  Do While loop 


what is the Javascript  do .. While loop?

1] Do while loop in JavaScript is a control flow statement that continually runs a block of code until a given condition is evaluated to false. 

2] While a do...while loop is similar to a while loop, the main distinction is that the code block is run at least once before the condition is verified.


Syntax :-

do 

{

code executed

}

while (condition)


do :-

1] keyword starts the loop.

2] block of code executed first.

while :-

1] keyword condition that is evaluated after execute of the block of code.

2] condition evaluates true  block of code executed again than condition false the loop terminates.

FlowChar :-

 Do while loop


javascript  do while loop 

1] Example

Q.  Display  Number 10 to 1 

Source code

let a=10;
do{
    console.log(a);
    a--;

}while (a>0);

Explain program :-

1] a starts at 10 .

2] loop prints value of a and decrement (a--) after each iteration 

3] condition run long i  greater than 0

 Do while loop

Display  Number 10 to 1 

Output 

Display  Number 10 to 1  javascript

JavaScript do  while loop 

2] Example

Q. display number 11 to 20 using do.. while loop


let i = 11;
do {
  console.log(i);
  i++;
} while (i <= 20);


JavaScript  do while loop 

Output :-

javascript  while loop


JavaScript  do while loop 


3] Example

Q. user input using do while loop


let input ;
do {
    input =prompt("Enter a no between 1 to 100 ");
}
while (input <1 || input > 100 );
console.log("enter your number- " +input);

JavaScript Do while loop

Output:- 

javascript do- while loop

JavaScript do while loop 

4] Example

Q. javascript that iteration 28 times 


let count =0;
do {
    console.log("count number-", count);
    count++;

}
while(count<28);

JavaScript  do while loop 

 Output:-

javascript  do while loop


Related Post :-

php program to print alphabet pattern R

php program to print half diamond pattern

javascript operators

how to create a navigation bar

Comments

Popular posts from this blog

HTML Tag

CSS Text Color Explained with Syntax and HTML Examples

HTML Input Type Submit Syntax and Example