Tag: equals Blind Date script input JS code ASC BOOL Operation Javascrip
JS scripting language, full-text JavaScript, the script language used in the Web page, very powerful language, where the comment syntax line comment//, multiline comment/* Comment content */, Output Syntax alert (information) plays the role of pop-up information, confirm pop up a dialog with the user interaction, Prompt popup A can let the user Input dialog box, embed the JS code as far as possible to write, <script type= "Text/javascript" ></script>, the program basically just, all the characters are all English half-width, In most cases, a semicolon is added after the end of each statement. Add a newline after each piece of code ends. The program echoes back and forth.
Type, integer int, single-precision decimal-float, double-decimal, character char, String, Boolean bool-true true false, numeric operator +-*/% + + + && | | ! > < >= <=. Concatenation of Strings +. The JS Basic Statement Branch statement includes the IF ternary operator else if switch. Loop statement.
Today I did a few exercises like comparing the size of XYZ, the code is as follows:
<script>
var x = prompt ("Please enter an integer x");
var y = prompt ("Please enter an integer y");
var z = prompt ("Please enter an integer z");
x = parseint (x);
y = parseint (y);
z = parseint (z);
if (x <= y && y <= z) {
var str = "Order is:" + x + "," + y + "," + Z ";
alert (str);
} else if (x <= z && z <= y) {
var str = "Order is:" + x + "," + z + "," + Y ";
alert (str);
} else if (x >= z && z >= y) {
var str = "Order is:" + y + "," + z + "," + X ";
alert (str);
} else if (x >= y && y >= z) {
var str = "Order is:" + z + "," + y + "," + X ";
alert (str);
} else if (y >= x && x >= z) {
var str = "Order is:" + z + "," + x + "," + Y ";
alert (str);
} else if (y >= z && z >= x) {
var str = "Order is:" + x + "," + z + "," + Y ";
alert (str);
// }
Like what
Enter the student's name, enter the test results if 100, "Congratulations you * * *, full score through!" "If it's greater than or equal to 80 less than 100," * *, you're excellent, keep it up! "If greater than or equal to 60 less than 80," * * score good "is greater than or equal to 50 less than 60," * * a little bit, next time must pass at least! "Less than 50," * * are you an idiot? 】。
var x = prompt ("Please enter name");
var y = prompt ("Please enter your score");
y = parseint (y);
if (y = = 100) {
var str = "Congratulations" + x + "," + "through";
alert (str);
} else if (y >= && y < 100) {
var str = +x + "You are excellent, keep going";
alert (str);
} else if (y >= && y <= 80) {
var str = +x + "Good score";
alert (str);
} else if (y >= && y < 60) {
var str = +x + "Almost, next time must pass";
alert (str);
} else if (y <50) {
var str = +x + "Are you stupid?" ";
alert (str);
//}
Blind Date process: Do you have a house? Do you have any money? Do you have the power? "Get married," "Buy a house before you get married," "Make money before you buy a house and then get married."
var x = prompt ("Do you have a house?");
if (x = = "has") {
var str = "Let's Get Married";
alert (str);
}else if (x = = "No") {
var y = prompt ("Do you have Money");
//}
if (y = = "has") {
var str = "Buy first house in marriage";
alert (str);
} else if (y = = "no") {
var z = prompt ("Do you have the ability to do it");
// }
if (z = = "has") {
var str = "Make money before you buy a house in marriage";
alert (str);
} else if (z = = "No") {
var str = "Goodbye";
alert (str);
// }
Standard weight: Men's weight = height -100±3 weight = height -110±3 Enter gender, height, weight, and see if weight is standard.
var x = prompt ("gender");
if (x = = "Male") {
var y = prompt ("height");
var z = prompt ("weight");
var a = y-100-3;
var B = y-100 + 3;
} if (Z > B) {
var m = z-b;
var height = "You are overweight" + m;
alert (height);
} else if (Z < a) {
var m = A-Z;
var height = "You are thinner than standard" + m;
alert (height);
}else if (x = = "female") {
var y = prompt ("height");
var z = prompt ("weight");
var a = y-110-3;
var B = y-110 + 3;
} if (Z > B) {
var m = z-b;
var height = "You are overweight" + m;
alert (height);
} else if (Z < a) {
var m = A-Z;
var height = "You are thinner than standard" + m;
alert (height);
}
JS scripting language