Are you a candidate looking to sharpen your skills? Try our practice tests or view sample interview questions & Get hired by the best. Click Here×

Online JavaScript Subjective Knowledge Test

Topics Covered

  • Dom Manuplication
  • Event loops
  • Hashes and Classes
  • Classes and Member functions
  • Conditionals and Alert Windows
  • String Interpolation (String Formatting)
  • Form Validation
  • Sorting
  • Inheritance
  • Ajax
  • Strings
  • Math object
  • Fibonacci
  • Events
  • LocalStorage
  • Geolocation

Useful for hiring

  • Javascript Developer
  • Javascript Programmer
  • Front end Developer

Start hiring job-fit candidates using this assessment

GET A DEMO

"Our recruitment team loves Interview Mocha especially for their skill assessments, simulators, and friendly support. Since using Interview Mocha, we interview only relevant candidates, and this has reduced our time to hire. Recruitment is no longer an hassle for us."

Christoph, e-Zest GmbH
Question

We need to discover a location in a web page where a mouse click happened.
Few lines in the Sample Program are missing (//Write your code here); you need to write the code to complete the program.

Sample Program:
document.onclick=mouseClick;

function mouseClick(evt) {
 evt = evt || window.event;
 var x = 0; var y = 0;

 if (evt.pageX) {
    x = evt.pageX;
    y = evt.pageY;
 
 } else if (evt.clientX) {
    var offsetX = 0; offsetY = 0;
 if (document.documentElement.scrollLeft) {
    ;
    offsetY = document.documentElement.scrollTop;
 } else if (document.body) {
    offsetX = document.body.scrollLeft;
    offsetY = document.body.scrollTop;
 }
;
 y = evt.clientY + offsetY;
 }

alert ("you clicked at x=" + x + " y=" + y);
}

Question

Following is the code to implement the function which can provide the random color code in RGB format.
Few lines in the Sample Program are missing (//Write your code here); you need to write the code to complete the program.

Sample Program:
function rndColor() {
var r = rndVl(255).toString(16);

;
 
 var g = rndVl(255).toString(16);
 if (g.length < 2) g= "0" + g;
 
 var b = rndVl(255).toString(16);
 if (b.length < 2) b= "0" + b;
 return "#" + r + g + b;
}

function rndVl(val) {
;
}
function rndColor() {
 return "rgb(" + rndVl(255) + "," + rndVl(255) + "," +
rndVl(255) + ")";
}

Good News! You can customize this test as per your requirement

  • Choose and add questions from Interview Mocha question libraries

  • Add your own set of questions

  • Customize test settings like duration, number of questions, passing score, web proctoring and much more

  • Mail us at support@interviewmocha.com to create a custom test

Looking for a tailor-made test, to suit your assessment needs?

Get in touch

Global companies using Mocha assessments

  • altran
  • credit suisse
  • sephora
  • nielsen
  • capgemini
  • akamai

How Mocha assessments are brewed

Speed up your IT recruitment with Interview Mocha

  • 500+ IT skill tests
  • 20+ coding languages
  • 50+ domain knowledge tests
  • 100+ digital 2.0 skill tests
  • Customer focus aptitude tests
  • Enterprise ready features & more...
GET A DEMO

Why hiring managers and recruiters across the globe love Interview Mocha

Take your first step to hire job fit candidates

GET A DEMO