Javascript Skill Test

  • Found this test from the internet (Download: JavaScript_Skill_Test-blank)
  • Tried to solve without using Google. FAILED.
  • With help from Google, solved questions. There was someone’s solution for exact same questions; I resisted a lot to not see his solution. Some questions are referred  to understand what question was.
  •  If I get this test in the interview without using internet, I probably failed completely. Need more study…
  • Solution: JavaScript_Skill_Test-solution

Javascript Skill Test

Q1. Fix the below JavaScript code so that the correct index is printed to console.log on each iteration.

Solution: [HTML] The loop finishes before the first timeout;thus, it shows 10 for 10 times. Solution is pass actual value of the loop to the setTimeout function. http://stackoverflow.com/a/5226349

Q2. Modify the below JavaScript so that it is called just after the DOM has loaded. No legacy browser support required.

Solution[HTML]

Q3. Modify the below code so that it will only display a message if the user is using Internet Explorer 7

Solution[HTML]

Q4. Finish the below JavaScript by implementing a simple flow control function (flow) that can take the provided array of functions and process them asynchronously before making a final callback.

Solution: [HTML]

Q5. Modify the below code so that the return value can also be returned with a callback function (if a callback function has been specified).

Solution[HTML]

Q6. Modify the below JavaScript code so that it uses a closure to return the response.

Solution[HTML]

Q7. Optimize the below JavaScript to minimize the number of redraws and reflows required.

Solution: [HTML]

Q8. Using the below JavaScript code as a starting point, implement a chain-able DOM Wrapper API that operates in a similar fashion to jQuery’s API (No native prototype extensions).

Solution[HTML]

Q9. The below JavaScript is used to handle mousemove events amongst 3 divs which are nested inside each other. Find and fix the problem which is causing too many events to get fired.

Solution: [HTML]