LinkedIn Assessments - JavaScript 2019-2021
- ~15 minutes duration
- 70th percentile required to pass and get a badge
- Retry in 3 months if you don’t pass
Q1. You've written the event listener shown below for a form button, but each time you click the button, the page reloads. Which statement would stop this from happening?
button.addEventListener('click', function(e) {
button.className = 'clicked';
}, false);
- e.preventDefault();
<p class="pull">Lorem Ipsum </p>
- document.querySelector(".pull");
Q3. Which statement is the correct way to create a variable called rate and assign it the value 100?
let rate = 100;
let modal = document.querySelector('#results');
setTimeout(function() {
modal.classList.remove('hidden');
}, 10000);
console.log('Results shown');
- Immediately
- var student = new Person();
- When you want your code to choose between multiple options.
- A for statement is generic but a forEach statement can be used only with an array.
addTax(50);
var Storm = function () {};
Storm.prototype.precip = 'rain';
var WinterStorm = function () {};
WinterStorm.prototype = new Storm();
WinterStorm.prototype.precip = 'snow';
var bob = new WinterStorm();
console.log(bob.precip);
- 'snow'
- It returns a reference to a variable in its parent scope.
"use strict";
function logThis() {
this.desc="logger";
console.log(this);
}
new logThis();
- logThis { desc: 'logger' }
console.log(typeof(42));
- 'Number'
- !==
Q14. Which statement is the correct way to create a variable called rate and assign it the value 100?
let rate = 100;
var student = new Person();
roadTypes[2]
- target
JSON.parse()
- When you want your code to choose between multiple options
for(var i=0; i<5; i++){
console.log(i);
}
- 01234
- Generator
Q22. You've written the code shown to log a set of consecutive values, but it instead results in the value 5, 5, 5, and 5 being logged to the console. Which revised version of the code would result in the value 1, 2, 3 and 4 being logged?
for (var i=1; i<=4; i++){
setTimeout(function(){
console.log(i);
}, i*10000);
}
for (var i = 1; i <= 4; i++) {{function(j) {setTimeout(function() {console.log(j);}, j * 1000);})(i)};
let discountPrice = function(price) { return price * 0.85; };
Q24. You need to match a time value such as 12:00:32. Which of the following regular expressions would work for your code?
- /\d\d:\d\d:\d\d/
let arr = [];
- 2
- instanceof
var start = 1;
if (start === 1) {
let end = 2;
}
- block
const x = 6 % 2;
const y = x ? 'One': 'Two';
- Two
- throw
- The defer attribute will asynchronously load the scripts in order
var a;
var b = (a = 3) ? true: false
- The condition in the ternary is using the assignment operator.
<p class="pull">lorem ipsum</p>
document.querySelector('.pull');
let answer = true;
if (answer === false) {
return 0;
} else {
return 10;
}
- 10
var start = 1;
function setEnd() {
var end = 10;
}
setEnd();
console.log(end);
- ReferenceError
function sayHello() {
console.log("hello");
}
console.log(sayHello.prototype);
- undefined
- Set
var a;
var b = (a = 3) ? true: false
- The condition in the ternary is using the assignment operator.
class X{
get Y(){return 42;}
}
var x = new X();
- x.Y
sum(10,20);
diff(10,20);
function sum(x,y){
return x+y;
}
let diff = function(x,y){
return x-y;
}
- ReferenceError
- Arguments
[] == [];
- False
- Side effects are not allowed.
- instanceof
const x = 6 % 2;
const y = x ? 'One' : 'Two';
- Two
let answer = true;
if (answer === false) {
return 0;
} else {
return 10;
}
- 10
function printA() {
console.log(answer);
var answer = 1;
}
printA();
printA();
- undefined then undefined
- to start tasks that might take some time without blocking subsequent tasks from executing immediately