├── .github └── FUNDING.yml └── README.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | patreon: adrinlol 4 | custom: "https://www.buymeacoffee.com/adrinlol" 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## LinkedIn JavaScript Assessment 2 | LinkedIn Assessments - JavaScript 2019-2021 3 | 4 | 5 | ## Overview 6 | #### Answer 15-20 timed, multiple-choice questions 7 | 8 | - ~15 minutes duration 9 | - 70th percentile required to pass and get a badge 10 | - Retry in 3 months if you don’t pass 11 | 12 | ---------------------------------------------------------- 13 | 14 | #### 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? 15 | ```javascript 16 | button.addEventListener('click', function(e) { 17 | button.className = 'clicked'; 18 | }, false); 19 | ``` 20 | 21 | - e.preventDefault(); 22 | 23 | ---------------------------------------------------------- 24 | 25 | #### Q2. Which statement references the DOM node created by the code shown? 26 | 27 | ``` 28 |

Lorem Ipsum

29 | ``` 30 | 31 | - document.querySelector(".pull"); 32 | 33 | ---------------------------------------------------------- 34 | 35 | #### Q3. Which statement is the correct way to create a variable called rate and assign it the value 100? 36 | 37 | ```javascript 38 | let rate = 100; 39 | ``` 40 | 41 | ---------------------------------------------------------- 42 | 43 | #### Q4. When would the final statement in the code shown be logged to the console? 44 | ```javascript 45 | let modal = document.querySelector('#results'); 46 | setTimeout(function() { 47 | modal.classList.remove('hidden'); 48 | }, 10000); 49 | console.log('Results shown'); 50 | ``` 51 | 52 | - Immediately 53 | 54 | ---------------------------------------------------------- 55 | 56 | #### Q5. Which statement creates a new object using the Person constructor? 57 | 58 | - var student = new Person(); 59 | 60 | ---------------------------------------------------------- 61 | 62 | #### Q6. When would you use a conditional statement? 63 | 64 | - When you want your code to choose between multiple options. 65 | 66 | ---------------------------------------------------------- 67 | 68 | #### Q7. How is forEach statement different from a for statement? 69 | 70 | - A for statement is generic but a forEach statement can be used only with an array. 71 | 72 | ---------------------------------------------------------- 73 | 74 | #### Q8. Review the code below. Which statement calls the addTax function and passes 50 as the argument? 75 | 76 | ```javascript 77 | addTax(50); 78 | ``` 79 | 80 | ---------------------------------------------------------- 81 | 82 | #### Q9. What is the result in the console of running the code shown? 83 | ```javascript 84 | var Storm = function () {}; 85 | Storm.prototype.precip = 'rain'; 86 | var WinterStorm = function () {}; 87 | WinterStorm.prototype = new Storm(); 88 | WinterStorm.prototype.precip = 'snow'; 89 | var bob = new WinterStorm(); 90 | 91 | console.log(bob.precip); 92 | 93 | ``` 94 | 95 | - 'snow' 96 | 97 | ---------------------------------------------------------- 98 | 99 | #### Q10. How does a function create a closure? 100 | 101 | - It returns a reference to a variable in its parent scope. 102 | 103 | ---------------------------------------------------------- 104 | 105 | #### Q11. What is the result in the console of running this code? 106 | ```javascript 107 | "use strict"; 108 | function logThis() { 109 | this.desc="logger"; 110 | console.log(this); 111 | } 112 | 113 | new logThis(); 114 | ``` 115 | 116 | - logThis { desc: 'logger' } 117 | 118 | ---------------------------------------------------------- 119 | 120 | #### Q12. What is the result of running this statement? 121 | ```javascript 122 | console.log(typeof(42)); 123 | ``` 124 | 125 | - 'Number' 126 | 127 | ---------------------------------------------------------- 128 | 129 | #### Q13. Which operator returns true if the two compared values are not equal? 130 | 131 | - !== 132 | 133 | ---------------------------------------------------------- 134 | 135 | #### Q14. Which statement is the correct way to create a variable called rate and assign it the value 100? 136 | 137 | ```javascript 138 | let rate = 100; 139 | ``` 140 | 141 | ---------------------------------------------------------- 142 | 143 | #### Q15. Which statement creates a new object using the Person constructor? 144 | 145 | ```javascript 146 | var student = new Person(); 147 | ``` 148 | 149 | ---------------------------------------------------------- 150 | 151 | #### Q16. How would you reference the text 'avenue' in the code shown? 152 | 153 | ```javascript 154 | roadTypes[2] 155 | ``` 156 | 157 | ---------------------------------------------------------- 158 | 159 | #### Q17. Which property references the DOM object that dispatched an event? 160 | 161 | - target 162 | 163 | ---------------------------------------------------------- 164 | 165 | #### Q18. Which method converts JSON data to a JavaScript object? 166 | 167 | ```javascript 168 | JSON.parse() 169 | ``` 170 | 171 | ---------------------------------------------------------- 172 | 173 | #### Q19. When would you use a conditional statement? 174 | 175 | - When you want your code to choose between multiple options 176 | 177 | ---------------------------------------------------------- 178 | 179 | #### Q20. What would be the result in the console of running this code? 180 | 181 | ```javascript 182 | for(var i=0; i<5; i++){ 183 | console.log(i); 184 | } 185 | 186 | ``` 187 | 188 | - 01234 189 | 190 | ---------------------------------------------------------- 191 | 192 | #### Q21. What is the name of a function whose execution can be suspended and resumed at a later point? 193 | 194 | - Generator 195 | 196 | ---------------------------------------------------------- 197 | 198 | #### 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? 199 | 200 | ```javascript 201 | for (var i=1; i<=4; i++){ 202 | setTimeout(function(){ 203 | console.log(i); 204 | }, i*10000); 205 | } 206 | 207 | ``` 208 | 209 | - ```for (var i = 1; i <= 4; i++) {{function(j) {setTimeout(function() {console.log(j);}, j * 1000);})(i)};``` 210 | 211 | ---------------------------------------------------------- 212 | 213 | #### Q23. Which statement creates a new function called discountPrice? 214 | 215 | - ```let discountPrice = function(price) { return price * 0.85; };``` 216 | 217 | ---------------------------------------------------------- 218 | 219 | #### Q24. You need to match a time value such as 12:00:32. Which of the following regular expressions would work for your code? 220 | 221 | - /\d\d:\d\d:\d\d/ 222 | 223 | ---------------------------------------------------------- 224 | 225 | #### Q25. How many prototype objects are in the chain for the following array? 226 | 227 | ```javascript 228 | let arr = []; 229 | 230 | ``` 231 | - 2 232 | 233 | ---------------------------------------------------------- 234 | 235 | #### Q26. Which of the following is not a unary operator? 236 | 237 | - instanceof 238 | 239 | ---------------------------------------------------------- 240 | 241 | #### Q27. What type of scope does the end variable have in the code shown? 242 | 243 | ```javascript 244 | var start = 1; 245 | if (start === 1) { 246 | let end = 2; 247 | } 248 | 249 | ``` 250 | - block 251 | 252 | ---------------------------------------------------------- 253 | 254 | #### Q28. What will the value of y be in this code: 255 | 256 | ```javascript 257 | const x = 6 % 2; 258 | const y = x ? 'One': 'Two'; 259 | 260 | ``` 261 | - Two 262 | 263 | ---------------------------------------------------------- 264 | 265 | #### Q29. Which keyword is used to create an error? 266 | 267 | - throw 268 | 269 | ---------------------------------------------------------- 270 | 271 | #### Q30. What's one difference between the async and defer attributes of the HTML script tag? 272 | 273 | - The defer attribute will asynchronously load the scripts in order 274 | 275 | ---------------------------------------------------------- 276 | 277 | #### Q31. The following program has a problem. What is it? 278 | 279 | ```javascript 280 | var a; 281 | var b = (a = 3) ? true: false 282 | 283 | ``` 284 | - The condition in the ternary is using the assignment operator. 285 | 286 | ---------------------------------------------------------- 287 | 288 | #### Q32. Which statement references the DOM node created by the code shown? 289 | 290 | ```javascript 291 |

lorem ipsum

292 | 293 | ``` 294 | - ```document.querySelector('.pull');``` 295 | 296 | ---------------------------------------------------------- 297 | 298 | #### Q33. What value does the code return? 299 | 300 | ```javascript 301 | let answer = true; 302 | if (answer === false) { 303 | return 0; 304 | } else { 305 | return 10; 306 | } 307 | 308 | ``` 309 | - 10 310 | 311 | ---------------------------------------------------------- 312 | 313 | #### Q34. What is the result in the console of running the code shown? 314 | 315 | ```javascript 316 | var start = 1; 317 | function setEnd() { 318 | var end = 10; 319 | } 320 | setEnd(); 321 | console.log(end); 322 | 323 | ``` 324 | - ReferenceError 325 | 326 | ---------------------------------------------------------- 327 | 328 | #### Q35. What will this code log in the console? 329 | 330 | ```javascript 331 | function sayHello() { 332 | console.log("hello"); 333 | } 334 | 335 | console.log(sayHello.prototype); 336 | 337 | ``` 338 | - undefined 339 | 340 | ---------------------------------------------------------- 341 | 342 | #### Q36. Which collection object allows unique value to be inserted only once? 343 | 344 | - Set 345 | 346 | ---------------------------------------------------------- 347 | 348 | #### Q37. The following program has a problem. What is it? 349 | 350 | ```javascript 351 | var a; 352 | var b = (a = 3) ? true: false 353 | 354 | ``` 355 | 356 | - The condition in the ternary is using the assignment operator. 357 | 358 | ---------------------------------------------------------- 359 | #### Q38. For the following class, how do you geet value of 42 from `x`? 360 | 361 | ```javascript 362 | 363 | class X{ 364 | get Y(){return 42;} 365 | } 366 | var x = new X(); 367 | 368 | ``` 369 | 370 | - x.Y 371 | 372 | ---------------------------------------------------------- 373 | #### Q39. What is the result? 374 | 375 | ```javascript 376 | 377 | sum(10,20); 378 | diff(10,20); 379 | 380 | function sum(x,y){ 381 | return x+y; 382 | } 383 | 384 | let diff = function(x,y){ 385 | return x-y; 386 | } 387 | 388 | ``` 389 | 390 | - ReferenceError 391 | 392 | ---------------------------------------------------------- 393 | 394 | #### Q40. Which variable is an implicit parameter for every function in JavaScript? 395 | 396 | - Arguments 397 | 398 | ---------------------------------------------------------- 399 | 400 | #### Q41. What does the following expression evaluate to? 401 | ```javascript 402 | 403 | [] == []; 404 | 405 | ``` 406 | - False 407 | 408 | ---------------------------------------------------------- 409 | 410 | #### Q42. Which statement is true about Functional Programming? 411 | 412 | - Side effects are not allowed. 413 | 414 | ---------------------------------------------------------- 415 | 416 | #### Q43. Which choice is not a unary operator? 417 | 418 | - instanceof 419 | 420 | ---------------------------------------------------------- 421 | 422 | #### Q44. What will the value of y be in this code: 423 | 424 | ```javascript 425 | 426 | const x = 6 % 2; 427 | const y = x ? 'One' : 'Two'; 428 | 429 | ``` 430 | 431 | - Two 432 | 433 | ---------------------------------------------------------- 434 | 435 | #### Q45. What value does this code return? 436 | 437 | ```javascript 438 | 439 | let answer = true; 440 | if (answer === false) { 441 | return 0; 442 | } else { 443 | return 10; 444 | } 445 | 446 | ``` 447 | 448 | - 10 449 | 450 | ---------------------------------------------------------- 451 | 452 | #### Q46. What two values will this code print? 453 | 454 | ```javascript 455 | 456 | function printA() { 457 | console.log(answer); 458 | var answer = 1; 459 | } 460 | printA(); 461 | printA(); 462 | 463 | ``` 464 | 465 | - undefined then undefined 466 | 467 | ---------------------------------------------------------- 468 | 469 | #### Q47. Why might you choose to make your code asynchronous? 470 | 471 | - to start tasks that might take some time without blocking subsequent tasks from executing immediately 472 | --------------------------------------------------------------------------------