Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

for loop with if statement

function get( num){
var a = num
//var a = new Array(3);
for (var i = 0; i <= 50; i++) {
  //a.push(i);
  if (a <= 40) {
   return "Yes its less than 40" ;
  }
else {
    return "No its more than 40" ;
  }
}
}
console.log(get(41));
Comment

if loop

if(<Condition>)
{
	<statement>
}
Comment

can we use for loop inside if statement

# Q: CAN WE USE A FOR LOOP INSIDE AN IF STATEMENT
# A: YES, YOU CAN PUT A FOR LOOP INSIDE AN IF STATEMENT. LIKE THIS:

myVar = 5
if myVar == 5:
  for i in range(myVar): # Prints out 01234 on separate lines
    print(i)
    
# You could also put an if statement in a for loop:
myNumber = 10
for i in range(myNumber):
  if i == 4:
    print("i is equal to 4")
Comment

Loop with If

squares = [i**2 for i in range(10) if i%2==0]
Comment

PREVIOUS NEXT
Code Example
Javascript :: using dot prototype with constructor in javascript 
Javascript :: switch element array angular 
Javascript :: react icons cdn 
Javascript :: how to Write a program that simulates a coin toss using random method of Javascript Math class 
Javascript :: player.filter 
Javascript :: js hide element 
Javascript :: substring in javascript 
Javascript :: javascript target closest id 
Javascript :: filter the falsy values out of an array in a very simple way! 
Javascript :: react axios fetchData with loading screen plus API 
Javascript :: identity-obj-proxy not working 
Javascript :: separador de miles javascript 
Javascript :: for each append to document 
Javascript :: Add New Properties to a JavaScript Object 
Javascript :: how to loop through all tags in html 
Javascript :: remove all chars from string and leave only numbers javascript and leav space betwin numbers 
Javascript :: React Javascript Builtin Hooks Import bug 
Javascript :: javaScript setMonth() Method 
Javascript :: tooltipster on dynamic content 
Javascript :: remove text in div jquery 
Javascript :: ejs tutorial 
Javascript :: json regex 
Javascript :: javascript table show only first n rows 
Javascript :: escape double quotes in json 
Javascript :: javascript check string empty 
Javascript :: send embed with webhook in JS 
Javascript :: push notification react native 
Javascript :: Highest Scoring Word 
Javascript :: react hook useeffect 
Javascript :: last index of string in javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =