JavaScript programming problem
The return value of the following two functions are the same as you? why?
function foo1() {
return {
bar: "hello"
};
}
function foo2() {
return
{
bar: "hello"
};
}
In programming languages, basically a semicolon (;) separated from the statement, which may increase the readability of the code and cleanliness. In the JS, should a separate line in half and statements, statements can often be omitted semicolons (;), JS parser to decide whether to automatically fill semicolon normal compilation according to whether:
var test = 1 + 2;
console.log(test); //3
In the above case, in order to correctly parsing code, will not be automatically filled with a semicolon, but to return, break, continue other statement is followed by wrapping, the parser will automatically fill in behind the semicolon (;), so the above second function this becomes:
function foo2() {
return;
{
bar: "hello"
};
}
So the second function is to return undefined.
MySQL programming problems
With a SQL statement, check out the name of the student in every subject is greater than 80 points.
Table name student_score
name | course | score |
---|---|---|
Joe Smith | Chinese | 81 |
Joe Smith | mathematics | 75 |
John Doe | Chinese | 76 |
John Doe | mathematics | 90 |
Wang Wu | Chinese | 81 |
Wang Wu | mathematics | 100 |
Wang Wu | English | 90 |
SELECT DISTINCT name FROM student_score
WHERE name NOT IN (SELECT DISTINCT name FROM student_score WHERE score<=80);
or
SELECT name FROM student_score GROUP BY name HAVING MIN(score)>80;
Java programming problem
Ball free fall from a height of 100 meters, the anti-jump back after each landing half its original height; down again, find it at the 10th floor, after a total of how many meters? 10th rebound tall?
Package Test; public class Test2 { / ** * * @param H from * @param n times * @return rebound height of the n-th * / public static Double sumBallHeight ( Double H, int n) { IF (n ==. 1 ) return H / 2 ; the else return sumBallHeight (H / 2, n--. 1 ); } public static void main (String [] args) { System.out.println (sumBallHeight ( 100, 10 )); } } Package Test; public class term TI2 { public static void sumBallHeight ( int initHeight, int Times) { // the number of meters after landing Double SUM = 0 ; // rebound height Double height = 0 ; for ( int I =. 1; I <= Times; I ++ ) { IF (I ==. 1 ) { height = initHeight / 2 ; SUM + = initHeight; } The else { SUM = SUM + height * 2 ; height = height / 2 ; } } System.out.println ( "first" + times + "landing times when, after a total of" + sum + "m" ); the System.out .println ( "first" + times + "rally" + height + "m" ); } public static void main (String [] args) { sumBallHeight ( 100,. 3 ); } }