Set 1-4

A visually engaging illustration of a JavaScript code editor with dynamic elements, quiz scoreboards, and colorful UI design elements representing coding, learning, and development.

JavaScript Proficiency Quiz

Test your JavaScript knowledge with our engaging quiz designed for developers of all levels. This quiz includes a variety of questions that cover fundamental concepts, advanced topics, and practical coding scenarios.

  • 10 challenging questions
  • Multiple choice and checkbox formats
  • Assess your coding skills and knowledge
10 Questions2 MinutesCreated by CodingCat321
Given the code below:
 
01 setCurrentUrl();
02 console.log('The current URL is: ' +url);
03
04 function setCurrentUrl() {
05     url = window.location.href;
06 }
 
What happens when the code executes?
The url variable has local scope and line 02 executes correctly
The url variable has local scope and line 02 throws an error
The url variable has global scope and line 02 executes correctly
The url variable has global scope and line 02 throws and error
Refer to the code below:
 
01 document.body.addEventListener('click', (event) => {
02      if(/* ANSWER HERE */){
03            console.log('myElement clicked');
04      }
05 });
 
Which replacement for the conditional statement on line 02 allows a developer to correctly determine that a specific element, myElement, on the page had been clicked?
E.nodeTarget == myElement
Button.addEventListener('click', 'myElement')
Event.target.id == 'myElement'
MyElement.clicked
Refer to the code below:
 
01 new Promise((resolve, reject) => {
02      const fraction = Math.random();
03      if(fraction > 0.5) reject('fraction > 0.5, ' + fraction);
04      resolve(fraction);
05 })
06 .then(() => console.log('resolved'))
07 .catch((error) => console.error(error))
08 .finally(() => console.log('when am I called?'));
 
When does Promise.finally on line 08 get called?
When resolved
When resolved and settled
When resolved or rejected
When rejected
A tesst has a dependency on database.query. During the test the dependency is replaced with an object called database with the method, query, that returns an array. The developer needs to verify how many times the method was called and the arguments used each time.
 
Which two test approaches describe the requirement?
 
Choose 2 answers
Integration
Mocking
White box
Black box
A developer created a generic function to log custom messages shown in the code below.
 
function myLog(message){
    console./*Answer goes here*/ ('Custom log: ' +message);
}
 
Which three options can the developer use to log custom messages in the console?
 
Choose 3 answers
Count
Group
Error
Trace
Debug
Which statement can a developer apply to increment the browser's navigation history without a page refresh?
Window.history.replaceState(newStateObject, '', null);
Window.history.pushState(newStateObject);
Window.history.pushState(newStateObject, '', null);
Window.history.state.push(newStateObject);
Given the code below:
 
const copy = JSON.stringify([new String('false'), new Boolean(false), undefined]);
 
What is the value of copy?
"["false", ()]"
"[false, ()]"
"["false", false, undefined]"
"["false", false, null]"
Cloud Kicks has a class to represent shoes for sale in an online store, as shown below:
 
01 class Shoe {
02     constructor(name, price) {
03         this.name = name;
04         this.price = price;
05     }
06
07     formattedPrice() {
08         return '$' + String(this.price);
09     }
10 }
 
A new business requirement comes in that requests a Sneaker class, that should have all of the properties and methods of the Shoe class, but will also have properties that are specific to sneakers.
 
Which line of code properly declares the Sneaker class such that it inherits from Shoe?
Class Shoe extends Sneaker {
Class Sneaker implements Shoe {
Class Sneaker extends Shoe {
Class Sneaker {
Refer to the code below:
 
let country = {
    get capital() {
         let city = Number("London");
 
         return {
              cityString: city.toString(),
         }
    }
}
 
Which value van a developer expect when referencing country.capital.cityString?
An error
"NaN"
Undefined
'London'
A developer has an isDog function that takes one argument, pet. They want to schedule the function to run every minute.
 
What is the correct syntax for scheduling this function?
SetTimeout(isDog('cat'), 60000);
SetInterval(isDog('cat'), 6000);
SetInterval(isDog, 60000, 'cat');
SetTimeout(isDog, 60000, 'cat');
{"name":"Set 1-4", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Test your JavaScript knowledge with our engaging quiz designed for developers of all levels. This quiz includes a variety of questions that cover fundamental concepts, advanced topics, and practical coding scenarios.10 challenging questionsMultiple choice and checkbox formatsAssess your coding skills and knowledge","img":"https:/images/course3.png"}
Powered by: Quiz Maker