Sie sind auf Seite 1von 3

*** All my SQL scripts are in MSSQL.

A. Section 1: Programming Questions


1. Question 1:
int Calculate(int max, int min = 1)
{
return max < min ? min : max * Calculate(max - 1, min);
}

2. Question 2:
- For better readable I really want split this method to two parts. My idea is we
will generate random number and then find a prime number less than it. I think it
gets better performance than two following ways:
- We get all prime number less than 100 and then get random from them.
- Random many times and stop random when it is a prime number.

bool IsPrime(int number)


{
if (number == 1) return false;
if (number == 2) return true;

int boundary = (int)Math.Floor(Math.Sqrt(number));

for (int i = 2; i <= boundary; ++i)


{
if (number % i == 0) return false;
}

return true;
}

int RandomPrime(int max = 100)


{
Random rnd = new Random();
int number = rnd.Next(2, max);

for (int i = number; i >= 2; i--)


{
if (IsPrime(i)) return i;
}

return 2;
}

B. Section 2: SQL Questions


3. Question 3:
SELECT u.user_id, count(l.book_isbn) AS count
FROM User u LEFT JOIN Loan l ON l.user_id = u.user_id
GROUP BY u.user_id

4. Question 4:
SELECT Date, ServiceType, Rating
FROM (SELECT Date, ServiceType, Rating,
row_number() over(partition by ServiceType order by Date desc) as rn
FROM ServiceRating) AS T
WHERE rn = 1

C. Section 3: Front-end Question (CSS and HTML)


5. Question 5:
- Result is blue.
- This example mentions about CSS -Priority rules
(weight). Im not a fan of css.

D. Section 4: JavaScript Question


- Look at the function2's body: f1(myVar) - should change to function1(myVar). When I
look at this line of code I don't know what's happenning @@.
- Look at the function4's body: I think you will want change to my function4 - I'm sure
about that =)).
- From now we should use typescript or es6 to avoid headache with var in JavaScript
@@.

var function4 = function() {


var myVar = { project: 1 };
function3(myVar);
console.log(myVar.project);
}

6. Question 6:
- Result is 1.
- Inside the function2 "myVar" always has value is 1 because this is local
scope. You can imagine this just is pass-by-value in the others strongly-typed
programming languages like C#, java etc.
7. Question 7:
- If you still want to keep your question then the result is 1.
- If you change function4 to my function above then the result is 2.

- In JavaScript it's always pass-by-value, but for objects the value of the
variable is a copy-reference.
- Please look at my function4 above: When the function4 is called, we get the
result is "2", because in JavaScript objects are always passed by copy-
reference this mean you can change objects properties value in the
function3 and then get there changed when the function3 is done executing,
but if you re-assign the object inside of the function3, this will not be visible
outside of the function3 since it was only a copy of the reference you changed.

8. Question 8:
- Explained above.

E. Section 5: Tell us More


9. Question 9:
- If you are looking for young, funny, a little bit passionate, like new
technology, can develop project from zero may be I suitable, otherwise you
should ignore me =))!
- I just a normal developer, can do many thing but not everything!
- Why you are interested to join us May be its a good place to improve my
English skill.

Das könnte Ihnen auch gefallen