js cycle exercise

var a=1;
while(a>0){
var b=prompt('input number');
if(b>a){
alert('big');
}
else if(b<a){
alert('small');
}
else{
alert('right');
}
}

/*var a=1;
console.log(isNaN(a));
*/

/*var password=123456;
do{
var a=Number(prompt('Please input password'));
if(password===a){
break;
}
}
while(true);* / 
/ * Var upwd = '123456'; 

do { 
// save entered passwords 
var STR = prompt ( 'INPUT password'); 
// you entered is determined whether the correct 
// If entered correctly, the end of the cycle 
if (str = upwd ==) { 
BREAK; 
} 
} the while (to true); * / 

 

// cycle produces all integers between 10 ~. 1 
/ * var. 1 = a; 
do { 
the console.log (a); 
a ++; 
} 
the while (a <= 10); * / 

// exercise: print cycle all integers between 30 to 20 is 
/ * var = 20 is a; 
do { 
the console.log (a); 
a ++; 
} 
the while (a <= 30); * / 
// print all between number divisible by 3 ~ 100. 1 
/ * var. 1 = a; 
do { 
IF (a 3% === 0) {
the console.log (A);  
}
A ++; 
} 
the while (A <= 100); * / 
// Exercise: calculating all be between 1 100 and 7 divisible digital 
/ * var A = 1; 
var = 0 SUM ; 
do { 
IF (a === 0. 7%) 
{ 
SUM = a +; 
} 
a ++; 
}; the while (a <= 100) 
(SUM) the console.log; 
* / 
// exercise: using a loop calculation factorial 10 
/ * var a = 10, B = 1; 
do { 
B * = a; 
A--; 
} 
the while (a> = 1) 
the console.log (B); * / 
// print all of the odd numbers between 1 and 100 
/ * var A =. 1; 
the while (A <= 100) 
{ 
IF (A ===. 1% 2) 
{ 
the console.log (A); 
} 
A ++;
} * / 
//Exercise: Calculate all integers between 1 and 100 
/ * var A = 1, SUM = 0; 
the while (A <= 100) 
{ 
SUM = A +; 
A ++; 
} 
the console.log (SUM); * / 

// Practice : calculated between 1 and 100 and all of the even 
/ * var a = 1; 
var SUM = 0; 
the while (a <= 100) 
{ 
IF (a 2% === 0) 
{ 
SUM = a +; 
} 
a ++; 
} 
the console.log (SUM); * / 
// exercise: calculating all even between 1 and 100, if skip encounters an odd 
/ * var I, SUM = 0; 
for (I = 0; I <= 100; ++ I) 
{ 
IF (I === 2%. 1) { 
Continue; 
} 
SUM = I +; 
} 
the console.log (SUM); * /
// print the century (2000 to 2100) before 10 leap year 
/ * var I, J = 0; 
for (I = 2000; I <= 2100; I ++) 
{ 
IF (I%. 4 === 0 && I% 100 =! || 0% 400 I = === 0) 
{ 
J ++; 
the console.log (I); 
IF (J === 10) 
{ 
BREAK; 
} 
} 
} * / 

// calculate all integers between 1 and 100 , if and when greater than 4000, ahead of the end loop, and print the current and 
/ * for (var I =. 1, SUM = 0; I <= 100; I ++) 
{ 
SUM + = I; 
iF (SUM> 4000) BREAK; 
} 
the console.log (SUM); 
* / 
// print multiplication table 

/ * for (var. 1 = I; I <=. 9; I ++) 
{ 
for (J = var. 1, T = ''; J <= I ; J ++) 
{ 
T + I + = '*' + J + '=' * + I + J ''; 
} 
the console.log (T);
}
 * / 

/ * for (var i =. 1, STR = ''; i <=. 5; i ++) { 
// i generated each time the spliced together 
str + = i + '* 5 = '+ (I *. 5) +' '; 
} 
the console.log (STR); * / 

 


// exercise: Print all integers between 1 and 100, and negative divisible by 3 numbers divisible by 4 
// if is divisible by 3 or 4, skip 
/ * for (var. 1 = A; A <= 100; A ++) 
{ 
IF (A || A 0% 3% 4 === === 0) 
{ 
Continue; 
} 
Console. log (A); 
} 
* / 

// for loop 
// print all integers between 1 and 10 
/ * 
for (var A = 1; A <= 10; A ++) 
{ 
the console.log (A); 
} 
* / 

/ / initial value cycling conditions, the increment 
@ exercise: calculated between all odd and 1 to 100
/ * 
For (var. 1 = A, SUM = 0; A <= 100; A ++) 
{ 
IF (A === 2%. 1) SUM = A +; 
} 
the console.log (SUM); 
* / 

// Exercise: Calculation number divisible by 3 of all the product 20 is between ~. 1 
/ * for (var. 1 = a, Product =. 1; a <= 20 is; a ++) 
{ 
IF (a === 0 3%) 
Product * = a; 
} 
the console.log (Product); 
* / 
var I = 0, SUM = 0 ;
 do { 
I ++ ;
 IF (I === 0% 2) Continue ;
 IF (I === 0. 5%) BREAK ; 
SUM = I +; // . 1. 3 + 
} the while (I <10 ); 
the console.log (SUM);

Guess you like

Origin www.cnblogs.com/lg614712/p/11845533.html