3 Months Free Update
3 Months Free Update
3 Months Free Update
Which function should a developer use to repeatedly execute code at a fixed interval ?
Refer to code below:
Let productSKU = ‘8675309’ ;
A developer has a requirement to generate SKU numbers that are always 19 characters lon,
starting with ‘sku’, and padded with zeros.
Which statement assigns the values sku0000000008675309 ?
Refer to the code below:
Which value can a developer expect when referencing country,capital,cityString?
A developer has an ErrorHandler module that contains multiple functions.
What kind of export should be leveraged so that multiple functions can be used?
Refer to code below:
Let first = ‘who’;
Let second = ‘what’;
Try{
Try{
Throw new error(‘Sad trombone’);
}catch (err){
First =’Why’;
}finally {
Second =’when’;
} catch (err) {
Second =’Where’;
}
What are the values for first and second once the code executes ?
A developer is setting up a new Node.js server with a client library that is built using events and callbacks.
The library:
? Will establish a web socket connection and handle receipt of messages to theserver
? Will be imported with require, and made available with a variable called we.
The developer also wants to add error logging if a connection fails.
Given this info, which code segment shows the correct way to set up a client with two events that listen at execution time?
Refer to HTML below:
contents.
Which expression outputs the screen width of the element with the ID card-01?
Given the code below:
Setcurrent URL ();
console.log(‘The current URL is: ‘ +url );
functionsetCurrentUrl() {
Url = window.location.href:
What happens when the code executes?
Refer to the code below:
Let inArray =[ [ 1, 2 ] , [ 3, 4, 5 ] ];
Which two statements result in the array [1, 2, 3, 4, 5] ?
Choose 2 answers
Refer to the code below:
Async funct on functionUnderTest(isOK) {
If (isOK) return ‘OK’;
Throw new Error(‘not OK’);
)
Which assertion accurately tests the above code?
A developer has the function, shown below, that is called when a page loads.
Where can the developer see the log statement after loading the page in the browser?
developer is trying to convince management that their team will benefit from using
Node.js for a backend server that they are going to create. The server will be a web server that
handles API requests from a website that the teamhas already built using HTML, CSS, and
JavaScript.
Which three benefits of Node.js can the developer use to persuade their manager?
Choose 3 answers:
A developer has the following array of hourly wages:
Let arr = (8, 5, 9, 75, 11, 25, 7, 75, , 13, 25);
For workers making less than $10 an hour rate should be multiple by 1.25 and returned in a new array.
How should the developer implement the request?
A developer wants to use a module named universalContainersLib and then call functions from it.
How should a developer import every function from the module and then call the functions foo and bar?
Given two expressions var1 and var2. What are two valid ways to return the logical AND
of the two expressions and ensure it is data type Boolean ?
Choose 2 answers:
Given the following code:
Counter = 0;
const logCounter = () => {
console.log(counter);
);
logCounter();
setTimeout(logCOunter, 1100);
setInterval(() => {
Counter++
logCounter();
}, 1000);
What is logged by the first four log statements?
Cloud Kicks has a class to represent items for sale in an online store, as shown below:
Class Item{
constructor (name, price){
this.name = name;
this.price = price;
}
formattedPrice(){
return ‘s’ + String(this.price);}}
A new business requirement comes in that requests a ClothingItem class that should have all of
the properties and methods of the Item class but will also have properties that are specific to
clothes.
Which line of code properly declares the clothingItem class such that it inherits from
Item?
A developer uses a parsed JSON string to work with user information as in the block below:
01 const userInformation ={
02 “ id ” : “user-01”,
03 “email” : “user01@universalcontainers.demo”,
04 “age” : 25
Which two options access the email attribute in the object?
Choose 2 answers
In the browser, the window object is often used to assign variables that require the broadest scope in an application Node.js application does not have access to the window object by default.
Which two methods areused to address this ?
Choose 2 answers
Refer to code below:
Function muFunction(reassign){
Let x = 1;
var y = 1;
if( reassign ) {
Let x= 2;
Var y = 2;
console.log(x);
console.log(y);}
console.log(x);
console.log(y);}
What is displayed when myFunction(true) is called?
A developer creates a simple webpage with an input field. When a user enters text in
the inputfield and clicks the button, the actual value of the field must be displayed in the
console.
Here is the HTML file content:
<button type =”button” >Display
The developer wrote the javascript codebelow:
Const button = document.querySelector(‘button’);
button.addEvenListener(‘click’, () => (
Const input = document.querySelector(‘input’);
console.log(input.getAttribute(‘value’));
When the user clicks the button, the output is always “Hello”.
What needs to be done make this code work as expected?
Refer to the code below
let inArray = [[1,2],[3,4,5]];
which two statements results in the array [1,2,3,4,5]?
choose 2 answer
A developer is asked to fix some bugs reported by users. To do that, the developer adds
abreakpoint for debugging.
Function Car (maxSpeed, color){
This.maxspeed =masSpeed;
This.color = color;
Let carSpeed = document.getElementById(‘ CarSpeed’);
Debugger;
Let fourWheels =new Car (carSpeed.value, ‘red’);
When the code execution stops at the breakpoint on line 06, which two types of information are
available in the browser console ?
Choose 2 answers:
Refer to the following array:
Let arr1 = [ 1,2, 3, 4, 5 ];
Which two lines of code result in a second array, arr2 being created such that arr2 is not
a reference to arr1?
Given the requirement to refactor the code above to JavaScript class format, which class
definition is correct?
A)
B)
C)
D)
A developer wants to use a try...catch statement to catch any error that countSheep () may throw and pass it to a handleError () function.
What is the correct implementation of the try...catch?
A)
B)
C)
D)
Refer to the expression below:
Let x = (‘1’ + 2) == (6 * 2);
How should this expression be modified to ensure that evaluates to false?
Refer to the code below:
let timeFunction =() => {
console.log(‘Timer called.”);
};
let timerId = setTimeout (timedFunction, 1000);
Which statement allows a developer to cancel the scheduled timed function?
Refer to the code below:
letsayHello = () => {
console.log (‘Hello, world!’);
};
Which code executes sayHello once, two minutes from now?
A developer wants to define a function log to be used a few times on a single-file JavaScript script.
01 // Line 1 replacement
02 console.log('"LOG:', logInput);
03 }
Which two options can correctly replaceline 01 and declare the function for use?
Choose 2 answers
Given code below:
setTimeout (()=> (
console.log(1);
). 0);
console.log(2);
New Promise ((resolve, reject )) = > (
setTimeout(() => (
reject(console.log(3));
). 1000);
)).catch(() => (
console.log(4);
));
console.log(5);
What is logged to the console?
Which code statement below correctly persists an objects inlocal Storage ?
In which situation should a developer include a try .. catch block around their function call ?
A developer writers the code below to calculate the factorial of a given number.
Function factorial(number) {
Return number + factorial(number -1);
}
factorial(3);
What is the resultof executing line 04?
Refer to the following array:
Let arr = [ 1,2, 3, 4, 5];
Which three options result in x evaluating as [3, 4, 5] ?
Choose 3 answers.
Given the code below:
Which method can be used to provide a visual representation of the list of users and to allow sorting by the name or email attribute?
Refer to the following code block:
class Animal{
constructor(name){
this.name = name;
}
makeSound(){
console.log(`${this.name} ismaking a sound.`)
}
}
class Dog extends Animal{
constructor(name){
super(name)
this.name = name;
}
makeSound(){
console.log(`${this.name} is barking.`)
}
}
let myDog = new Dog('Puppy');
myDog.makeSound();
What is the console output?
Refer to the code below:
Function changeValue(obj) {
Obj.value = obj.value/2;
}
Const objA = (value: 10);
Const objB = objA;
changeValue(objB);
Const result = objA.value;
What is the value of result after the code executes?
A test 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
A developer at Universal Containers is creating their new landing pagebased on HTML, CSS, and JavaScript. The website includes multiple external resources that are loaded when the page is opened.
To ensure that visitors have a good experience, a script named personalizeWebsiteContent needs to be executed when the webpage isloaded and there is no need to wait for the resources to be available.
Which statement should be used to call personalizeWebsiteContent based on the above business requirement?
A developer is leading the creation of a new browser application that will serve a single
page application. The team wants to use a new web framework Minimalsit.js.The Lead
developer wants to advocate for a more seasoned web framework that already has a
community around it.
Which two frameworks should the lead developer advocate for?
Choose 2 answers
Given the code below:
const copy = JSON.stringify([ newString(‘ false ’), new Bollean( false ), undefined ]);
What is the value of copy?
A developer wants to create an object from a function in the browser using the code
below:
Function Monster() { this.name = ‘hello’ };
Const z = Monster();
What happens due to lackof the new keyword on line 02?
A developer is required to write a function that calculates the sum of elements in an
array but is getting undefined every time the code is executed. The developer needs to find
what is missing in the code below.
Const sumFunction = arr => {
Return arr.reduce((result, current) => {
//
Result += current;
//
), 10);
);
Which option makes the code work as expected?
A developer has two ways to write a function:
Option A:
function Monster() {
This.growl = () => {
Console.log (“Grr!”);
}
}
Option B:
function Monster() {};
Monster.prototype.growl =() => {
console.log(“Grr!”);
}
After deciding on an option, the developer creates 1000 monster objects.
How many growl methods are created with Option A Option B?
Refer to the code below:
const car = {
price:100,
getPrice:function(){
return this.price;
}
};
const customCar = Object.create(car);
customCar.price = 70;
delete customCar.price;const result = customCar.getPrice();
Whatis the value of result after the code executes?
Refer to the code declarations below:
Which three expressions return the string JavaScript?
Choose 3 answers
A developer is setting up a Node,js server and is creating a script at the root of the source code, index,js, that will start the server when executed. The developer declares a variable that needsthe folder location that the code executes from.
Which global variable can be used in the script?
A test has a dependency on database. query. During the test, the dependency is replaced with an object called database with the method,
Calculator query, that returns an array. The developer does notneed to verify how many times the method has been called.
Which two test approaches describe the requirement?
Choose 2 answers
A developer wants to leverage a module to print a price in pretty format, and has imported a method as shown below:
Import printPrice from ‘/path/PricePrettyPrint.js’;
Based on the code, what mustbe true about the printPrice function of the PricePrettyPrint module for this import to work ?
Given the code below:
const delay = async delay =>{
return new Promise((resolve,reject)=>{
console.log(1);
setTimeout(resolve,deleay);
});
};
const callDelay =async ()=>{
console.log(2);
const yup = await delay(1000);
console.log(3);
}
console.log(4);
callDelay();
console.log(5);
What is logged to the console?
A developer has an ErrorHandler module that contains multiple functions.
What kind of export be leverages so that multiple functions can beused?
Refer to the code below:
01 const exec = (item, delay) =>{
02 newPromise(resolve => setTimeout( () => resolve(item), delay)),
03 async function runParallel() {
04 Const (result1, result2, result3) = await Promise.all{
05 [exec (‘x’, ‘100’) , exec(‘y’, 500), exec(‘z’, ‘100’)]
06 );
07 return `parallel is done: $(result1)$(result2)$(result3)`;
08 }
}
}
Which two statements correctly execute the runParallel () function?
Choose 2 answers
A developer wants to create an object from a function in the browser using the code below.
What happens due to the lack of the mm keyword on line 02?
Teams at Universal Containers (UC) work on multiple JavaScript projects at the same time.
UC is thinking about reusability and how each team can benefit from the work of others.
Going open-source or public is not an option at this time.
Which option is available to UC with npm?
A developer has code that calculates a restaurant bill, but generates incorrect answers
while testing the code:
function calculateBill (items ) {
let total = 0;
total += findSubTotal(items);
total += addTax(total);
total += addTip(total);
return total;
}
Which option allows the developer to step into each function execution within calculateBill?
is below:
The JavaScript portion is:
01 functionpreviewFile(){
02 const preview = document.querySelector(‘img’);
03 const file = document.querySelector(‘input[type=file]’).files[0];
04 //line 4 code
05 reader.addEventListener(“load”, () => {
06 preview.src = reader.result;
07 },false);
08 //line 8 code
09 }
In lines 04 and 08, which code allows the user to select an image from their local
computer , and to display the image in the browser?