option
Questions
ayuda
daypo
search.php

jsdev1

COMMENTS STATISTICS RECORDS
TAKE THE TEST
Title of test:
jsdev1

Description:
Lorem ipsum dolor sit amet

Creation Date: 2024/01/30

Category: Others

Number of questions: 149

Rating:(0)
Share the Test:
Nuevo ComentarioNuevo Comentario
New Comment
NO RECORDS
Content:

1.) 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 needs the folder location that the code executes from. Which global variable can be used in the script?. _dirname. _filename. this.path. window.location.

2.) 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. [].concat(...inArray);. [].concat.apply([], inArray);. [ ].concat.apply(inArray,[ ]);. [ ].concat([...inArray]).

3.) 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 not need to verify how many times the method has been called. Which two test approaches describe the requirement? Choose 2 answers (Chat GPT answers: Stubbing, Substitution). White box. Substitution. Stubbing. Black box.

4.) Which statement parses successfully?. JSON. parse (' "foo" ');. JSON.parse (" 'foo' ");. JSON.parse ("foo");. JSON.parse ('foo');.

5.) Refer to following code block: let array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; let output = 0; for (let num of array) { ‎ ‎ ‎ ‎ ‎‎ if (output > 10) { break; } ‎ ‎ ‎ ‎ ‎ if (num % 2 == 0) { continue; } ‎ ‎ ‎ ‎ ‎ output += num; } What is the value of output after the code executes?. 16. 36. 11. 25.

6.) 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 result of executing line 04?. RuntimeError. -Infinity. 6. 0.

7.) Refer to following code: class Vehicle { ‎ ‎ ‎ ‎ ‎ constructor(plate) { ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ this.plate = plate; ‎ ‎ ‎ ‎ ‎ } } class Truck extends Vehicle { ‎ ‎ ‎ ‎ ‎ constructor(plate, weight) { ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ //Missing code ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ this.weight = weight; ‎ ‎ ‎ ‎ ‎ } ‎ ‎ ‎ ‎ ‎ displayWeight() { ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ console.log(`The truck ${this.plate} has a weight of ${this.weight} lb.`); ‎ ‎ ‎ ‎ ‎ } } let myTruck = new Truck('123AB', 5000); myTruck.displayWeight(); Which statement should be added to line 09 for the code to display 'The truck 123AB has a weight of 5000lb.'?. super(plate);. Vehicle.plate = plate;. this.plate = plate;. super.plate = plate;.

8.) 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. let x = arr.splice(2,3);. let x = arr.slice(2);. let x = arr.filter((a) => { return a>2 });. let x = arr.slice(2,3);. let x = arr.filter((a) => (a<2));.

9.) 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 must be true about the printPrice function of the PricePrettyPrint module for this import to work?. printPrice must be the default export. printPrice must be be a named export. printPrice must be an all export. printPrice must be a multi export.

10.) A 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 team has already built using HTML, CSS, and JavaScript. Which three benefits of Node.js can the developer use to persuade their manager? Choose 3 answers: Executes server-side JavaScript code to avoid learning a new language. Installs with its own package manager to install and manage third-party libraries. Uses non-blocking functionality for performance request handling. Performs a static analysis on code before execution to look for runtime errors. Ensures stability with one major release every few years.

11.) 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?. setTimeout(function() { ‎ ‎ ‎ ‎ ‎ try { ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ countSheep(); } catch (e) { ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ handleError(e); ‎ ‎ ‎ ‎ ‎ } }, 1000);. try { ‎ ‎ ‎ ‎ ‎ countSheep(); } handleError(e) { ‎ ‎ ‎ ‎ ‎ catch(e); }. try { ‎ ‎ ‎ ‎ ‎ setTimeout(function() { ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ countSheep(); ‎ ‎ ‎ ‎ ‎ }, 1000); } catch (e) { ‎ ‎ ‎ ‎ ‎ handleError(e); }. try { ‎ ‎ ‎ ‎ ‎ countSheep(); } finally { ‎ ‎ ‎ ‎ ‎ handleError(e); }.

12.) 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?. class ClothingItem extends Item {. class ClothingItem implements Item {. class ClothingItem {. class ClothingItem super Item {.

13.) Refer to the expression below: let x = ('1' + 2) == (6 * 2); How should this expression be modified to ensure that evaluates to false?. let x = ('1' + 2) === (6 * 2);. let x = ('1' + ' 2') == (6 * 2);. let x = (1 + 2) == ('6' / 2);. let x = (1 + 2 ) == (6 / 2);.

14.) developer removes the HTML class attribute from the checkout button, so now it is simply: <button>Checkout</button> There is a test to verify the existence of the checkout button, however it looks for a button with class = "blue". The test fails because no such button is found. Which type of test category describes this test?. False negative. False positive. True negative. True positive.

15.) Refer to the code below: const pi = 3.1415326 What is the data type of pi?. Number. Double. Decimal. Float.

16.) Given the code below: [Refer to the image] What should a developer insert at line 15 to output the following message using the method? > SNEGeneziz is loading a cartridgegame: Super Monic 3x Force . . . Console16bit.prototype.load = function(gamename) {. Console16bit.prototype.load(gamename) {. Console16bit = Object.create(GameConsole.prototype).load = function(gamename) {. Console16bit.prototype.load(gamename) = function() {.

17.) Which two code snippets show working examples of a recursive function? Choose 2 answers. let countingDown = function(startNumber) { ‎ ‎ ‎ ‎ ‎ if(startNumber > 0) { ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ console.log(startNumber); ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ return countingDown(startNumber); ‎ ‎ ‎ ‎ ‎ } else { return startNumber; } };. function factorial (numVar) { ‎ ‎ ‎ ‎ ‎‎if(numVar < 0) return; ‎ ‎ ‎ ‎ ‎if(numVar === 0) return 1; ‎ ‎ ‎ ‎ ‎‎return numVar -1; }. const sumToTen = numVar => { ‎ ‎ ‎ ‎ ‎if(numVar < 0) return; ‎ ‎ ‎ ‎ ‎return sumToTen(numVar + 1) };. const factorial = numVar => { ‎ ‎ ‎ ‎ ‎if(numVar < 0) return; ‎ ‎ ‎ ‎ ‎if(numVar === 0 ) return 1; ‎ ‎ ‎ ‎ ‎return numVar * factorial(numVar - 1 ); };.

18.) Which three actions can be using the JavaScript browser console? Choose 3 answers: ('Run code that is not related to page' is also very plausible). View, change, and debug the JavaScript code of the page. View and change DOM the page. Display a report showing the performance of a page. Run code that is not related to page. View and change security cookies.

19.) Refer to the code below: function changeValue(param) { ‎ ‎ ‎ ‎ ‎ param = 5; } let a = 10; let b = a; changeValue(b); const result = a + ' - ' + b; What is the value of result when the code executes?. 10-10. 5-5. 10-5. 5-10.

20.) 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 Minimalist.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. Vue. Angular. Express. Koa.

21.) A developer wants to setup a secure web server with Node.js. The developer creates a directory locally called app-server, and the first file is app-server/index.js. Without using any third-party libraries, what should the developer add to index.js to create the secure web server?. const https = require('https');. const server = require('secure-server');. const tls = require('tls');. const http = require('http');.

22.) Refer to the code below: let str = 'javascript'; str[0] = 'J'; str[4] = 'S'; After changing the string index values, the value of str is 'javascript'. What is the reason for this value: Primitive values are immutable. Non-primitive values are mutable. Non-primitive values are immutable. Primitive values are mutable.

23.) 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? Choose 2 answers. let arr2 = arr1.slice(0, 5);. let arr2 = Array.from(arr1);. let arr2 = arr1;. let arr2 = arr1.sort();.

24.) Given the following code: let x = ('15' + 10) * 2; What is the value of a?. 3020. 1520. 50. 35.

25.) Which three statements are true about promises? Choose 3 answers. A Promise has a .then() method. A settled promise can become resolved. A pending promise can become fulfilled, settled, or rejected. A fulfilled or rejected promise will not change states. The executor of a new Promise runs automatically.

26.) A developer has the function, shown below, that is called when a page loads. function onload() { ‎ ‎ ‎ ‎ ‎ console.log("Page has loaded!"); } Where can the developer see the log statement after loading the page in the browser?. Browser JavaScript console. Browser performance tools. Terminal running the web server. On the webpage.

27.) Refer to the code below: console.log('Start'); Promise.resolve('Success') ‎ ‎ ‎ ‎ ‎ .then(function(value) { ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ console.log('Success'); ‎ ‎ ‎ ‎ ‎ }); console.log('End'); What is the output after the code executes successfully?. Start End Success. Start Success End. End Start Success. Success Start End.

28.) A developer uses a parsed JSON string to work with userInformation as in the block below: const userInformation = { ‎ ‎ ‎ ‎ ‎ ‎ "id": "user-01", ‎ ‎ ‎ ‎ ‎ ‎ "email": "user01@universalcontainers.demo", ‎ ‎ ‎ ‎ ‎ ‎ "age": 25 } Which two options access the email attribute in the object? Choose 2 answers. userInformation.get("email"). userInformation.email. userInformation["email"]. userInformation(email).

29.) Refer to the code snippet below: let array = [1, 2, 3, 4,4, 5, 4, 4]; for (let i = 0; i < array.length; i++) { ‎ ‎ ‎ ‎ ‎ if (array[i] === 4) { ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ array.splice(i, 1); ‎ ‎ ‎ ‎ ‎ } } What is the value of the array after the code executes?. [1, 2, 3, 4, 5, 4]. [1, 2, 3, 5]. [1, 2, 3, 4, 4, 5, 4]. [1, 2, 3, 4, 5, 4, 4].

30.) Which three options show valid methods for creating a fat arrow function? Choose 3 answers. x => { console.log('executed'); }. ( ) => { console.log('executed'); }. (x,y,z) => { console.log('executed'); }. x,y,z => { console.log('executed'); }. [ ] => { console.log('executed'); }.

31.) Refer to code below: 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?. First is Why and second is When. First is Who and second is Where. First is Why and second is Where. First is Who and second is When.

32.) Which javascript methods can be used to serialize an object into a string and deserialize a JSON string into an object, respectively?. JSON.stringify and JSON.parse. JSON.serialize and JSON.deserialize. JSON.encode and JSON.decode. JSON.parse and JSON.deserialize.

33.) 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?. clearTimeout(timerId);. removeTimeout(timedFunction);. removeTimeout(timerId);. clearTimeout(timedFunction);.

34.) Refer to the code below: What is the value of result when Promise.race executes?. Car 2 completed the race. Race is cancelled. Car 1 crashed in the race. Car 3 completed the race.

35.) The developer wants to test the array shown: const arr = Array(5).fill(0); Which two tests are the most accurate for this array? Choose 2 answers: console.assert(arr.length === 5);. arr.forEach(elem => console.assert(elem === 0));. console.assert(arr[0] === 0 && arr[arr.length] === 0);. console.assert (arr.length >0);.

36.) Refer to the code below: let foodMenu1 = ['pizza', 'burger', 'French fries']; let finalMenu = foodMenu1; finalMenu.push('Garlic bread'); What is the value of foodMenu1 after the code executes?. ['pizza', 'Burger', 'French fires', 'Garlic bread']. ['pizza','Burger', 'French fires']. ['Garlic bread' , 'pizza','Burger', 'French fires']. ['Garlic bread'].

37.) Refer to the code below: let sayHello = () => { ‎ ‎ ‎ ‎ ‎ console.log ('Hello, world!'); }; Which code executes sayHello once, two minutes from now. setTimeout(sayHello, 12000);. setInterval(sayHello, 12000);. setTimeout(sayHello(), 12000);. delay(sayHello, 12000);.

38.) A developer wrote a fizzbuzz function that when passed in a number, returns the following: 'Fizz' if the number is divisible by 3. 'Buzz' if the number is divisible by 5. 'Fizzbuzz' if the number is divisible by both 3 and 5. Empty string if the number is divisible by neither 3 or 5. Which two test cases will properly test scenarios for the fizzbuzz function? Choose 2 answers. let res = fizzbuzz(5); console.assert (res === ' ');. let res = fizzbuzz(15); console.assert (res === 'fizzbuzz');. let res = fizzbuzz(Infinity); console.assert (res === ' ' );. let res = fizzbuzz(3); console.assert (res === 'buzz');.

39.) Which two console logs output NaN? Choose 2 answers. console.log(10 / ''five");. console.log(parseInt('two'));. console.log(10/0);. console.log(10/Number('5'));.

40.) A developer implements a function that adds a few values. function sum(num) { ‎ ‎ ‎ ‎ ‎ ‎ if (num == undefined) { num = 0; } ‎ ‎ ‎ ‎ ‎ ‎ return function(num2, num3) { ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ if (num3 === undefined) { num3 = 0; } ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ return num + num2 + num3; ‎ ‎ ‎ ‎ ‎ ‎ } } Which three options can the developer invoke for this function to get a return value of 10? Choose 3 answers. sum(5)(5). sum(10)(). sum()(5, 5). sum(5, 5)(). sum()(10).

41.) Which statement accurately describes the behaviour of the async/await keywords?. The associated function will always return a promise. The associated class contains some asynchronous functions. The associated function can only be called via asynchronous methods. The associated sometimes returns a promise.

42.) 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. White box. Mocking. Black box. Integration.

43.) Refer to the code below: for(let number=2 ; number <= 5 ; number += 1 ) { ‎ ‎ ‎ ‎ ‎ ‎ // insert code statement here } The developer needs to insert a code statement in the location shown. The code statement has these requirements: 1. Does not require an import 2. Logs an error when the boolean statement evaluates to false 3. Works in both the browser and Node.js Which meet the requirements?. console.error(number % 2 === 0);. assert(number % 2 === 0);. console.assert(number % 2 === 0);. console.debug(number % 2 === 0);.

44.) 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?. 1000 growl methods are created for Option A. 1 growl method is created for Option B. 1 growl method is created for Option A. 1000 growl methods are created for Option B. 1000 growl methods are created regardless of which option is used. 1 growl method is created regardless of which option is used.

45.) Given the following code: document.body.addEventListener('click', (event) => { ‎ ‎ ‎ ‎ ‎ ‎ if (/* CODE REPLACEMENT HERE */) { ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ console.log('button clicked!'); ‎ ‎ ‎ ‎ ‎ ‎ } }); Which replacement for the conditional statement on line 02 allows a developer to correctly determine that a button on page is clicked?. event.target.nodeName == 'BUTTON'. button.addEventListener('click'). e.nodeTarget == this. Event.clicked.

46.) Given the code below: const copy = JSON.stringify([ ‎ ‎ ‎ ‎ ‎ new String('false'), ‎ ‎ ‎ ‎ ‎ new Boolean(false), ‎ ‎ ‎ ‎ ‎ undefined ]); What is the value of copy?. '["false",false,null]'. '["false",false,undefined]'. '[false,{ }]'. ["false",{ }].

47.) What are two unique features of functions defined with a fat arrow as compared to normal function definition? Choose 2 answers. The function generated its own "this" making it useful for separating the function's scope from its enclosing scope. The function receives an argument that is always in scope, called parentThis, which is the enclosing lexical scope. If the function has a single expression in the function body, the expression will be evaluated and implicitly returned. The function uses the "this" from the enclosing scope.

48.) A developer wrote the following code: let X = object.value; try { ‎ ‎ ‎ ‎ ‎ handleObjectValue(X); } catch (error) { ‎ ‎ ‎ ‎ ‎ handleError(error); } The developer has a getNextValue function to execute after handleObjectValue(), but does not want to execute getNextValue() if an error occurs. How can the developer change the code to ensure this behavior?. try { ‎ ‎ ‎ ‎ ‎ handleObjectValue(x); } catch(error) { ‎ ‎ ‎ ‎ ‎ handleError(error); } then { ‎ ‎ ‎ ‎ ‎ getNextValue(); }. try { ‎ ‎ ‎ ‎ ‎ handleObjectValue(x); } catch(error) { ‎ ‎ ‎ ‎ ‎ handleError(error); } finally { ‎ ‎ ‎ ‎ ‎ getNextValue(); }. try { ‎ ‎ ‎ ‎ ‎ handleObjectValue(x); } catch(error) { ‎ ‎ ‎ ‎ ‎ handleError(error); } getNextValue();. try { ‎ ‎ ‎ ‎ ‎ handleObjectValue(x) ........................

49.) Given the code below: setCurrentUrl(); console.log('The current URL is: ' + url); function setCurrentUrl() { ‎ ‎ ‎ ‎ ‎ url = window.location.href; } What happens when the code executes?. The url variable has global scope and line 02 executes correctly. The url variable has local scope and line 02 throws an error. The url variable has local scope and line 02 executes correctly. The url variable has global scope and line 02 throws an error.

50.) A developer has an ErrorHandler module that contains multiple functions. What kind of export should be leveraged so that multiple functions can be used?. Named. All. Multi. Default.

51.) A developer creates a simple webpage with an input field. When a user enters text in the input field and clicks the button, the actual value of the field must be displayed in the console. Here is the HTML file content: <input type="text" value="Hello" name="input"/> <button type="button">Display</button> The developer wrote the javascript code below: 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?. Replace line 04 with console.log(input.value);. Replace line 03 with const input = document.getElementByName('input');. Replace line 02 with button.addEventListener("onclick", function() {. Replace line 02 with button.addCallback("click", function() {.

52.) Universal Containers recently launched its new landing page to host a crowd-funding campaign. The page uses an external library to display some third-party ads. Once the page is fully loaded, it creates more than 50 new HTML items placed randomly inside the DOM, like the one in the code below: <!-- This is an ad --> <div class="ad-library-item ad-hidden" onload="myFunction()"> ‎ ‎ ‎ ‎ ‎ ‎ <img src="/ad-library/ad01.gif" /> </div> All the elements includes the same ad-library-item class. They are hidden by default, and they are randomly displayed while the user navigates through the page. Tired of all the ads, what can the developer do to temporarily and quickly remove them?. Use the browser to execute a script that removes all the element containing the class "ad-library-item". Use the DOM inspector to prevent the load event to be fired. Use the DOM inspector to remove all the elements containing the class ad-library-item. Use the browser console to execute a script that prevents the load event to be fired.

53.) Developer has a web server running with Node.js. The command to start the web server is node server,js. The web server started having latency issues. Instead of a one second turn around for web requests, the developer now sees a five second turnaround, Which command can the web developer run to see what the module is doing during the latency period?. NODE_DEBUG = http, https node server.js. DEBUG = true node server.js. DEBUG = http, https node server.js. NODE_DEBUG = true node server.js.

54.) Refer to HTML below: <div id="main"> ‎ ‎ ‎ ‎ ‎ <div id="card-00">This card is smaller.</div> ‎ ‎ ‎ ‎ ‎ <div id="card-01">The width and height of this card is determined by its contents.</div> </div> Which expression outputs the screen width of the element with the ID card-01?. document.getElementById('card-01').getBoundingClientRect().width. document.getElementById('card-01').style.width. document.getElementById('card-01').width. document.getElementById(' card-01 ').innerHTML.length.

55.) 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?. Replace line 05 with return result;. Replace line 03 with if(arr.length == 0 ) ( return 0; ). Replace line 04 with result = result +current;. Replace line 02 with return arr.map(( result, current) => (.

56.) 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 the server * Will be imported with require, and made available with a variable called ws. 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?. ws.connect(() => { ‎ ‎ ‎ ‎ ‎ console.log('connected to client'); }).catch((error) => { ‎ ‎ ‎ ‎ ‎ console.log('ERROR' , error); });. ws.on('connect', () => { ‎ ‎ ‎ ‎ ‎ console.log('connected toclient'); ‎ ‎ ‎ ‎ ‎ ws.on('error', (error) => { ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ console.log('ERROR' , error); ‎ ‎ ‎ ‎ ‎ }); });. ws.on('connect', () => { ‎ ‎ ‎ ‎ ‎ console.log('connected to client'); }); ws.on('error', (error) => { ‎ ‎ ‎ ‎ ‎ console.log('ERROR' , error); });. try { ‎ ‎ ‎ ‎ ‎ ws.connect(() => { ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ console.log('connected to client'); ‎ ‎ ‎ ‎ ‎ }); } catch(error) { ‎ ‎ ‎ ‎ ‎ console.log('ERROR' , error); }.

57.) Given the JavaScript below: function filterDOM (searchString) { ‎ ‎ ‎ ‎ ‎ const parsedSearchString = searchString && searchString.toLowerCase(); ‎ ‎ ‎ ‎ ‎ document.querySelectorAll('.account').forEach(account => { ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ const accountName = account.innerHTML.toLowerCase(); ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ account.style.display = accountName.includes(parsedSearchString) ? /*Insert code*/; ‎ ‎ ‎ ‎ ‎ )}; } Which code should replace the placeholder comment on line 05 to hide accounts that do not match the search string?. ' block ' : ' none '. ' visible ' : ' hidden '. ' name ' : ' block '. ' hidden ' : ' visible '.

58.) Why would a developer specify a package.json as a developed forge instead of a dependency ?. It is only needed for local development and testing. It is required by the application in production. Other required packages depend on it for development. It should be bundled when the package is published.

59.) A developer has the following array of student test grades: let arr = [7, 8, 5, 8, 9]; The teacher wants to double each score and then see an array of the students who scored more than 15 points. How should the developer implement the request?. let arr1 = arr.map((num) => num * 2).filter((val) => val > 15);. let arr1 = arr.mapBy ((num) => { return num * 2 }).filterBy((val ) => return val > 15 ));. let arr1 = arr.filter(( val) => { return val > 15 }).map((num) => { return num * 2 });. let arr1 = arr.map((num) => (num * 2)).filterBy((val) => (val > 15));.

60.) A developer is asked to fix some bugs reported by users. To do that, the developer adds a breakpoint for debugging. function Car(maxSpeed, color) { ‎ ‎ ‎ ‎ ‎ this.maxSpeed = maxSpeed; ‎ ‎ ‎ ‎ ‎ 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: The style, event listeners, and other attributes applied to the carSpeed DOM element. The information stored in the window.localStorage property. The values of the carSpeed and fourWheels variables. A variable displaying the number of instances created for the Car Object.

61.) Refer to the code below: const event = new CustomEvent( //Missing Code ); obj.dispatchEvent(event); A developer needs to dispatch a custom event called update to send information about recordId. Which two options could a developer insert at the placeholder in line 02 to achieve this? Choose 2 answers. 'update' , { ‎ ‎ ‎ ‎ ‎ detail: { ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ recordId : '123abc' ‎ ‎ ‎ ‎ ‎ } }. 'update' , '123abc'. 'update' , { ‎ ‎ ‎ ‎ ‎ recordId : '123abc' }. { type : 'update', recordId: '123abc' }.

62.) Which option is a core Node.js module?. Path. Ios. Memory. locate.

63.) A developer is wondering whether to use, Promise.then or Promise.catch, especially when a Promise throws an error? Which two promises are rejected? Which 2 are correct?. Promise.reject('cool error here').catch(error => console.error(error));. new Promise((resolve, reject) => { throw 'cool error here' }).catch(error => console.error(error));. new Promise(() => { throw 'cool error here' }).then(null, error => console.error(error)));. Promise.reject('cool error here').then(error => console.error(error));.

64.) Refer to the following code: 01 function Tiger() { 02 ‎ ‎ ‎ ‎ ‎ this.Type = 'Cat'; 03 ‎ ‎ ‎ ‎ ‎ this.size = 'large'; 04 } 05 06 let tony = new Tiger(); 07 tony.roar = () => { 08 ‎ ‎ ‎ ‎ ‎ console.log('They\'re great1'); 09 }; 10 11 function Lion() { 12 ‎ ‎ ‎ ‎ ‎ this.type = 'Cat'; 13 ‎ ‎ ‎ ‎ ‎ this.size = 'large'; 14 } 15 16 let leo = new Lion(); 17 // Insert code here 18 leo.roar(); Which two statements could be inserted at line 17 to enable the function call on line 18? Choose 2 answers. Object.assign(leo, tony);. leo.prototype.roar = () => { console.log('They\'re pretty good:'); };. leo.roar = () => { console.log('They\'re pretty good:'); };. Object.assign(leo, Tiger);.

65.) Refer to the code below: 01 const exec = (item, delay) => { 02 ‎ ‎ ‎ ‎ ‎ new Promise(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. async runParallel().then(data);. runParallel().then(data);. runParallel().done(function(data){ return data; });. runParallel().then(function(data) return data.

66.) 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 are used to address this? Choose 2 answers. Assign variables to the global object. Assign variables to module.exports and require them as needed. Use the document object instead of the window object. Create a new window object in the root file.

67.) The developer wants to test this code: const toNumber = (strOrNum) => strOrNum; Which two tests are most accurate for this code? Choose 2 answers. console.assert(toNumber('2') ===2);. console.assert(toNumber('-3') < 0);. console.assert(toNumber () === NaN);. console.assert(Number.isNaN(toNumber()));.

68.) 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 replace line 01 and declare the function for use? Choose 2 answers. const log = (logInput) => {. function leg(logInput) {. const log(loginInput) {. function log = (logInput) {.

69.) A Developer wrote the following code to test a sum3 function that takes in an array of numbers and returns the sum of the first three number in the array, The test passes: 01 let res = sum2([1, 2, 3]); 02 console.assert(res === 6); 03 04 res = sum3([1, 2, 3, 4]); 05 console.assert(res === 6); A different developer made changes to the behavior of sum3 to instead sum all of the numbers present in the array. The test passes: Which two results occur when running the test on the updated sum3 function? Choose 2 answers. The line 02 assertion passes. The line 02 assertion fails. The line 05 assertion fails. The line 05 assertion passes.

70.) 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?. Using the debugger command on line 05. Using the debugger command on line 03. Calling the console.trace(total) method on line 03. Wrapping findSubtotal in a console.log() method.

71.) 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?. Private packages can be scoped, and scopes can be associated to a private registries. Private registries are not supported by npm, but packages can be installed via URL. Private packages are not supported, but they can use another package manager like yarn. Private registries are not supported by npm, but packages can be installed via git.

72.) A developer has a formatName function that takes two arguments, firstName and lastName and returns a string. They want to schedule the function to run once after five seconds. What is the correct syntax to schedule this function?. setTimeout(() => { formatName('John', 'Doe') }, 5000);. setTimeout ('formatName', 5000, 'John", "Doe');. setTimeout (formatName(), 5000, "John", "Doe");. setTimeout (formatName('John', ''Doe'), 5000);.

73.) Universal Container (UC) just launched a new landing page, but users complain that the website is slow. A developer found some functions that cause this problem. To verify this, the developer decides to do everything and log the time each of these three suspicious functions consumes. console.time('Performance'); maybeAHeavyFunction(); thisCouldTakeTooLong(); orMaybeThisOne(); console.endTime('Performance'); Which function can the developer use to obtain the time spent by every one of the three functions?. console.timeLog(). console.getTime(). console.trace(). console.timeStamp().

74.) Developer publishes a new version of a package with new features that do not break backward compatibility. The previous version number was 1.1.3. Following semantic versioning format, what should the new package version number be?. 1.2.0. 2.0.0. 1.2.3. 1.1.4.

75.) Refer to the code snippet: function getAvailabilityMessage(item) { ‎ ‎ ‎ ‎ ‎ if (getAvailability(item)) { ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ var msg = "Username available"; ‎ ‎ ‎ ‎ ‎ } ‎ ‎ ‎ ‎ ‎ return msg; } A developer writes this code to return a message to user attempting to register a new username. If the username is available, variable. What is the return value of msg when getAvailabilityMessage("newUserName") is executed and getAvailability("newUserName") returns false?. undefined. "Username available". "newUserName". "Msg is not defined".

76.) Refer to the following code: let sampleText = 'The quick brown fox jumps'; A developer needs to determine if a certain substring is part of a string. Which three expressions return true for the given substring? Choose 3 answers. sampleText.includes('fox');. sampleText.includes(' fox ');. sampleText.includes(' quick ') !== -1;. sampleText.includes(' quick ', 4);. sampleText.includes('Fox ', 3).

77.) Refer to the code below: function foo() { ‎ ‎ ‎ ‎ ‎ const a = 2; ‎ ‎ ‎ ‎ ‎ function bar() { ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ console.log(a); ‎ ‎ ‎ ‎ ‎ } ‎ ‎ ‎ ‎ ‎ return bar; } Why does the function bar have access to variable a?. Outer function's scope. Inner function's scope. Hoisting. Prototype chain.

78.) Refer to the code below: let o = { ‎ ‎ ‎ ‎ ‎ get js() { ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ let city1 = String("st. Louis"); ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ let city2 = String(" New York "); ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ return { ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ firstCity: city1.toLowerCase(), ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ secondCity: city2.toLowerCase(), ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ } ‎ ‎ ‎ ‎ ‎ } } What value can a developer expect when referencing o.js.secondCity?. ' new york '. ' New York '. An error. Undefined.

79.) Refer to the HTML below: <div id="main"> ‎ ‎ ‎ ‎ ‎ <ul> ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ <li>Leo</li> ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ <li>Tony</li> ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ <li>Tiger</li> ‎ ‎ ‎ ‎ ‎ </ul> </div> Which JavaScript statement results in changing " Tony" to "Mr. T."?. document.querySelector('#main li:nth-child(2)').innerHTML = ' Mr. T. ';. document.querySelectorAll('#main #TONY').innerHTML = ' Mr. T. ';. document.querySelector('#main li:second-child').innerHTML = ' Mr. T. ';. document.querySelector('#main li.Tony').innerHTML = ' Mr. T. ';.

80.) Refer to code below: 01 function Person() { ‎02 ‎ ‎ ‎ ‎ this.firstName = 'John'; 03 } 04 05 Person.prototype = { 06 ‎ ‎ ‎ ‎ ‎ job: x => 'Developer' 07 }; 08 09 const myFather = new Person(); 10 const result = myFather.firstName + ' ' + myFather.job(); What is the value of the result after line 10 executes?. John Developer. Error: myFather.job is not a function. Undefined Developer. John undefined.

81.) Refer to the following code: let obj = { foo: 1, bar: 2 }; let output = []; for (let something in obj) { ‎ ‎ ‎ ‎ ‎ output.push(something); } console.log(output); What is the output line 11?. ["foo", "bar"]. ["bar","foo"]. [1,2]. ["foo:1","bar:2"].

82.) Which statement accurately describes an aspect of promises?. Arguments for the callback function passed to .then() are optional. .then() cannot be added after a catch. In a.then() function, returning results is not necessary since callbacks will catch the result of a previous promise. .then() manipulates and returns the original promise.

83.) A class was written to represent items for purchase in an online store, and a second class representing items that are on sale at a discounted price. The constructor sets the name to the first value passed in. The pseudocode is below: class Item { constructor(name, price) { // Constructor Implementation } } class SaleItem extends Item { constructor (name, price, discount) { // Constructor Implementation } } There is a new requirement for a developer to implement a description method that will return a brief description for Item and SaleItem. let regItem = new Item('Scarf', 55); let saleItem = new SaleItem('Shirt', 80, -1); Item.prototype.description = function () { return 'This is a ' + this.name; } console.log(regItem.description()); console.log(saleItem.description()); SaleItem.prototype.description = function () { return 'This is a discounted ' + this.name; } console.log(regItem.description()); console.log(saleItem.description()); What is the output when executing the code above?. This is a Scarf This is a Shirt This is a Scarf This is a discounted Shirt. This is a Scarf Uncaught TypeError: saleItem.description is not a function This is a Shirt This is a did counted Shirt. This is a Scarf Uncaught TypeError: saleItem.description is not a function This is a Scarf This is a discounted Shirt. This is a Scarf This is a Shirt This is a discounted Scarf This is a discounted Shirt.

84.) In which situation should a developer include a try...catch block around their function call?. The function might raise a runtime error that needs to be handled. The function results in an out of memory issue. The function has an error that should not be silenced. The function contains scheduled code.

85.) is below: The JavaScript portion is: 01 function previewFile() { 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?. 04 const reader = new FileReader(); 08 if (file) reader.readAsDataURL(file);. 04 const reader = new File(); 08 if (file) URL.createObjectURL(file);. 04 const reader = new File(); 08 if (file) reader.readAsDataURL(file);. 04 const reader = new FileReader(); 08 if (file) URL.createObjectURL(file);.

86.) Refer to the following code that imports a module named utils: import (foo, bar) from '/path/Utils.js'; foo(); bar(); Which two implementations of Utils.js export foo and bar such that the code above runs without error? Choose 2 answers. // FooUtils.js and BarUtils.js exist import (foo) from '/path/FooUtils.js'; import (bar) from ' /path/NarUtils.js';. const foo = () => { return 'foo'; } const bar = () => { return 'bar'; } export { bar, foo }. export default class { foo() { return 'foo'; } bar() { return 'bar'; } }. const foo = () => { return 'foo'; } const bar = () => { return 'bar'; } export default foo, bar;.

87.) Refer to the code below: 01 const server = require('server'); 02 /* Insert code here */ A developer imports a library that creates a web server. The imported library uses events and callbacks to start the servers Which code should be inserted at the line 03 to set up an event and start the web server ?. server.on('connect'. (port) => { console.log('Listening on ', port); }). server.start();. server(). serve((port) => (. console.log( 'Listening on ', port);.

88.) Refer to the code below? let searchString = 'look for this'; Which two options remove the whitespace from the beginning of searchString? Choose 2. searchString.trimStart();. searchString.replace(/*\s\s*/, '');. answers searchString.trimEnd();. trimStart(searchString);.

89.) Refer to the code below: function Person(firstName, lastName, eyeColor) { this.firstName = firstName; this.lastName = lastName; this.eyeColor = eyeColor; } Person.job = 'Developer'; const myFather = new Person('John', 'Doe'); console.log(myFather.job); What is the output after the code executes?. Undefined. Developer. ReferenceError: assignment to undeclared variable "Person". ReferenceError: eyeColor is not defined.

90.) 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?. Boolean(var1 && var2). Boolean(var1) && Boolean(var2). var1.toBoolean() && var2.toBoolean(). var1 && var2.

91.) Refer to the code below: const resolveAfterMilliseconds = (ms) => Promise.resolve( setTimeout( () => console.log(ms), ms ) ); const aPromise = await resolveAfterMilliseconds(500); const bPromise = await resolveAfterMilliseconds(500); await aPromise, wait bPromise; What is the result of running line 05?. Neither aPromise or bPromise runs. aPromise and bPromise run sequentially. aPromise and bPromise run in parallel. Only aPromise runs.

92.) Given the following code: let x = null; console.log(typeof x); What is the output of line 02?. "object'. ''undefined''. ''null'''. ''x''.

93.) A developer wants to iterate through an array of objects and count the objects and count the objects whose property value, name, starts with the letter N. const arrObj = [{"name" : "Zach"}, {"name" : "Kate"}, {"name" : "Alise"}, {"name" : "Bob"}, {"name" : "Natham"}, {"name" : "nathaniel"}]; Refer to the code snippet below: 01 arrObj.reduce((acc, curr) => { 02 // missing line 02 03 // missing line 03 04 }, 0); Which missing lines 02 and 03 return the correct count?. const sum = curr.name.startsWith('N') ? 1 : 0; return acc + sum;. const sum = curr.startsWith('N') ? 1 : 0; return acc + sum;. const sum = curr.startsWith('N') ? 1 : 0; return curr + sum;. const sum = curr.name.startsWIth('N') ? 1 : 0; return curr + sum;.

94.) Refer to the code below: <html lang="en"> <table onclick="console.log('Table log');"> <tr id="row1"> <td>Click me!</td> </tr> </table> <script> function printMessage(event) { console.log('Row log'); } let elem = document.getElementById('row1'); elem.addEventListener('click', printMessage, false); </script> </html> Which code change should be made for the console to log only Row log when 'Click me!' is clicked?. Add event.stopPropagation(); to printMessage function. Add event.removeEventListener(); to window.onLoad event handler. Addevent.removeEventListener(); to printMessage function. Add.event.stopPropagation(); to window.onLoad event handler.

95.) Consider type coercion, what does the following expression evaluate to? True + 3 + '100' + null. '4100null'. 104. 4100. '3100null'.

96.) A developer implements and calls the following code when an application state change occurs: const onStateChange = innerPageState => { window.history.pushState(newPageState, ' ', null); } If the back button is clicked after this method is executed, what can a developer expect?. The page is navigated away from and the previous page in the browser's history is loaded. A navigate event is fired with a state property that details the previous application state. A pop state event is fired with a state property that details the application's last state. The page reloads and all Javascript is reinitialized.

97.) Refer to code below: let a = 'a'; let b; // b = a; console.log(b); What is displayed when the code executes?. Undefined. ReferenceError: b is not defined. a. null.

98.) A developer needs to test this function: 01 const sum3 = (arr) => { 02 if (!arr.length) return 0; 03 if (arr.length === 1) return arr[0]; 04 if (arr.length === 2) return arr[0] + arr[1]; 05 return arr[0] + arr[1] + arr[2]; 06 }; Which two assert statements are valid tests for the function? Choose 2 answers. console.assert(sum3([1, '2']) == 12);. console.assert(sum3([-3, 2]) == -1);. console.assert(sum3([0]) == 0);. console.assert(sum3(['hello', 2, 3, 4]) === NaN);.

99.) Which code statement below correctly persists an objects in local storage?. const setLocalStorage = (storageKey, jsObject) => { window.localStorage.setItem(storageKey, JSON.stringify(jsObject)); }. const setLocalStorage = (jsObject) => { window.localStorage.connectObject(jsObject)); }. const setLocalStorage = (jsObject) => { window.localStorage.setItem(jsObject); }. const setLocalStorage = (storageKey, jsObject) => { window.localStorage.persist(storageKey, jsObject); }.

100.) Given code below: setTimeout(() => { console.log(1); }, 0); console.log(2); new Promise((resolve, reject) => { setTimeout(() => { console.log(3); reject(); }, 1000); }).catch(() => { console.log(4); }); console.log(5); What is logged to the console?. 25134. 21435. 12435. 12534.

101.) Given the code below: const delay = sync delay => { return new Promise((resolve, reject) => { setTimeout (resolve, delay); }); }; const callDelay = async () => { const yup = await delay(1000); console.log(1); } What is logged to the console?. 2 3 1. 1 2 3. 1 3 2. 2 1 3.

102.) Refer to the code below: let textValue = '1984'; Which code assignment shows a correct way to convert this string to an integer?. let numberValue = Number(textValue);. let numberValue = (Number) textValue;. let numberValue = textValue.toInteger();. let numberValue = Integer(textValue);.

103.) Universal Containers (UC) notices that its application that allows users to search for accounts makes a network request each time a key is pressed. This results in too many requests for the server to handle. To address this problem, UC decides to implement a debounce function on string change handler. What are three key steps to implement this debounce function?. If there is an existing setTimeout and the search string change, allow the existing setTimeout to finish, and do not enqueue a new setTimeout. When the search string changes, enqueue the request within a setTimeout. Ensure that the network request has the property 'debounce' set to true. If there is an existing setTimeout and the search string changes, cancel the existing setTimeout using the persisted timerId and replace it with a new setTimeout. Store the timeId of the setTimeout last enqueued by the search string change handle.

104.) 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?. import * as lib from '/path/universalContainersLib.js'; lib.foo(); lib.bar();. import all from '/path/universalContainersLib.js'; universalContainersLib.foo(); universalContainersLib.bar();. import { foo, bar } from '/path/universalContainersLib.js'; foo(); bar();. import * from '/path/universalContainersLib.js'; universalContainersLib.foo(); universalContainersLib.bar();.

105.) Refer to code below: let productSKU = '8675309' ; A developer has a requirement to generate SKU numbers that are always 19 characters long, starting with 'sku', and padded with zeros. Which statement assigns the values sku0000000008675309?. productSKU = productSKU.padStart(16, '0').padStart(19, 'sku');. productSKU = productSKU.padEnd (16. '0').padstart(19, 'sku');. productSKU = productSKU.padEnd (16. '0').padstart('sku');. productSKU = productSKU.padStart (19. '0').padstart('sku');.

106.) Refer to the code below: function changeValue(param) { param = 5; } let a = 10; let b = 5; changeValue(b); const result = a + " - " + b;. 10 - 5. 10 - 10. 5 - 5. 5 - 10.

107.) Universal Containers (UC) just launched a new landing page, but users complain that the website is slow. A developer found some functions any that might cause this problem. To verify this, the developer decides to execute everything and log the time each of these three suspicious functions consumes. Which function can the developer use to obtain the time spent by every one of the three functions? console.time('Performance'); maybeAHeavyFunction(); thisCouldTakeTooLong(); orMaybeThisOne(); console.endTime('Performance');. console.timeLog(). console.timeStamp(). console.trace(). console.getTime ().

108.) A developer receives a comment from the Tech Lead that the code given below has error: 01 const monthName = 'July'; 02 const year = 2019; 03 if(year === 2019) { monthName = 'June'; } Which line edit should be made to make this code run?. 01 let monthName = 'July';. 02 let year = 2019;. 02 const year = 2020;. 03 if (year == 2019) {.

109.) function Vehicle(name, price) { this.name = name; this.price = price; } Vehicle.prototype.priceInfo = function() { return `Cost of the ${this.name} is ${this.price}$`; } Given the requirement to refactor the code above to JavaScript class format, which class definition is correct?. class Vehicle { constructor(name, price) { this.name = name; this.price = price; } priceInfo() { return `Cost of the ${this.name} is ${this.price}$`; } }. class Vehicle { vehicle(name, price) { this.name = name; this.price = price; } priceInfo() { return `Cost of the ${this.name} is ${this.price}$`; } }. class Vehicle { constructor(name, price) { name = name; price = price; } priceInfo() { return `Cost of the ${this.name} is ${this.price}$`; } }. class Vehicle { constructor() { this.name = name; this.price = price; } priceInfo() { return `Cost of the ${this.name} is ${this.price}$`; } }.

110.) Refer to the code below: const searchText = 'Yay! Salesforce is amazing!'; let result1 = searchText.search(/sales/i); let result2 = searchTest.search(/sales/i); console.log(result1); console.log(result2); After running this code, which result is displayed on the console?. >5 >undefined. >true >false. >5 >-1. >5 >0.

111.) A developer is debugging a web server that uses Node.js. The server hits a runtime error every third request to an important endpoint on the web server. The developer added a break point to the start script, that is at index.js at the root of the server's source code. The developer wants to make use of chrome DevTools to debug. Which command can be run to access DevTools and make sure the breakdown is hit?. node --inspect index.js. node inspect index.js. node --inspect-brk index.js. node -i index.js.

112.) A developer uses the code below to format a date. const date = new Date(2020, 05, 10); const dateDisplayOptions = { year: 'numeric', month: 'long', day: 'numeric', }; const formattedDate = date.toLocaleDateString('en', dateDisplayOptions); After executing, what is the value of formattedDate?. May 10, 2020. June 10, 2020. October 05, 2020. November 05, 2020.

113.) Given a value, which three options can a developer use to detect if the value is NaN? Choose 3 answers. Object.is(value, NaN). value !== value. Number.isNaN(value). value === Number.NaN. value == NaN.

114.) Refer to code below: console.log(0); setTimeout(() => { console.log(1); }); console.log(2); setTimeout(() => {console.log(3); }, 0); console.log(4); In which sequence will the numbers be logged?. 02413. 01234. 02431. 13024.

115.) Refer to the following code: function test(val) { if (val === undefined) { return 'Undefined values!'; } if (val === null) { return 'Null value! '; } return val; } let x; test(x); What is returned by the function call on line 13?. 'Undefined values!'. Undefined. Line 13 throws an error. 'Null value!'.

116.) A developer is working on an ecommerce website where the delivery date is dynamically calculated based on the current day. The code line below is responsible for this calculation. const deliveryDate = new Date(); Due to changes in the business requirements, the delivery date must now be: today's date + 9 days. Which code meets this new requirement?. deliveryData.setDate( new Date( deliveryDate.getDate() + 9 ) );. deliveryDate.setDate( Date.current () + 9);. deliveryDate.date = new Date(+9) ;. deliveryDate.date = Date.current () + 9;.

117.) Refer to HTML below: <p> The current status of an Order: <span id ="status"> In Progress </span> </p> Which JavaScript statement changes the text 'In Progress' to 'Completed'?. document.getElementById("status").innerHTML = 'Completed';. document.getElementById("status").Value = 'Completed' ;. document.getElementById("#status").innerHTML = 'Completed' ;. document.getElementById(".status").innerHTML = 'Completed' ;.

118.) (stopped at 121) Given the HTML below: <div> <div id="row-uc">Universal Containers</div> <div id="row-as">Applied Shipping<div> <div id="row-bt">Burlington Textiles</div> </div> Which statement adds the priority-account css class to the Applied Shipping row?. document.querySelector(‘#row-as’).classes.push(‘priority-account’);. document.queryElementById(‘row-as’).addclass(‘priority-account’);. document.querySelector(‘#row-as’).classList.add(‘priority-account’);. document.querySelectorALL(‘#row-as’).classList.add(‘priority-account’);.

119.) 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 lack of the new keyword on line 02?. window.name is assigned to 'hello' and the variable z remains undefined. Window.m is assigned the correct object. The z variable is assigned the correct object. The z variable is assigned the correct object but this.name remains undefined.

120.) 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?. console.assert(await functionUnderTest(true), 'OK'). console.assert(await functionUnderTest(true), ' OK '). console.assert(await functionUnderTest(true), ' notOK '). console.assert(await functionUnderTest(true), ' not OK ').

121.) What are two unique features of functions defined with a fat arrow as compared to normal function definition? Choose 2 answers. If the function has a single expression in the function body, the expression will be evaluated and implicitly returned. The function uses the this from the enclosing scope. The function generated its own this making it useful for separating the function's scope from its enclosing scope. The function receives an argument that is always in scope, called parentThis, which is the enclosing lexical scope.

122.) Refer to the code below: const addBy = ? const addByEight = addBy(8); const sum = addByEight(50); Which two functions can replace line 01 and return 58 to sum? Choose 2 answers. const addBy = function(num1) { ‎ ‎ ‎ ‎ ‎ return function(num2) { ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ return num1 + num2; ‎ ‎ ‎ ‎ ‎ } }. const addBy = (num1) => (num2) => num1 + num2;. const addBy = (num1) => num1 + num2 ;. const addBy = function(num1){ ‎ ‎ ‎ ‎ ‎ return num1 + num2; }.

123.) A developer writes the code below to return a message to a user attempting to register a new username. If the username is available, a variable named msg is declared and assigned a value on line 03. 01 function getAvailabilityMessage(item) { 02 if( getAvailability(item) ) { 03 var msg = "Username available"; 04 } 05 return msg; 06 } What is the value of msg when getAvailabilityMessage("newUserName") is executed and getAvailability("newUserName") returns true?. Username available. "msg is not defined". undefined. "newUserName".

124.) Refer to the code below: const myFunction = arr => { return arr.reduce((result, current) => { return result = current; }, 10); } What is the output of this function when called with an empty array?. Returns 10. Throws an error. Returns 0. Returns NaN.

125.) Refer to the code: function Animal(size, type) { this.size = size || "small"; this.type = type || "Animal"; this.canTalk = false; } let Pet = function (size, type, name, owner) { Animal.call(this, size, type); this.name = name; this.owner = owner; } Pet.prototype = Object.create(Animal.prototype); let pet1 = new Pet(); console.log(pet1); Given the code above, which three properties are set for pet1? Choose 3 answers: Owner. Name. Type. Size. canTalk.

126.) Given the following code: let x = ('15' + 10) * 2; What is the value of a?. 1520. 35. 50. 3020.

127.) A developer creates a class that represents a blog post based on the requirement that a Post should have a body author and view count. The Code shown Below: class Post { // Insert code here this.body =body this.author = author; this.viewCount = viewCount; } } Which statement should be inserted in the placeholder on line 02 to allow for a variable to be set to a new instanceof a Post with the three attributes correctly populated?. constructor(body, author, viewCount). constructor() {. super (body, author, viewCount) {. function Post (body, author, viewCount) {.

128.) "bar, awesome" is a popular JavaScript module. the versions publish to npm are: 1.2 1.3.1 1.3.5 1.4.0 Teams at Universal Containers use this module in a number of projects. A particular project has the package.json definition below. { "name": "UC Project Extra", "version": "0.0.5", "dependencies": { "bar.awesome": "~1.3.0" } } A developer runs this command: npm install. Which version of bar, awesome is installed?. 1.3.5. 1.3.1. 1.4.0. The command fails, because version 130 is not found.

129.) 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?. 2 2 1 2. 2 2 undefined undefined. 2 2 2 2. 2 2 1 1.

130.) let total = 10; const interval = setInterval(() => { total++; clearInterval(interval); total++; }, 0); total++; console.log(total);. 11. 12. 10. 13.

131.) A developer wrote the following code to test a sum3 function that takes in an array of numbers and returns the sum of the first three numbers in the array, and the test passes. A different developer made changes to the behavior of sum3 to instead sum only the first two numbers present in the array. 01 let res = sum3([1, 4, 11]); 02 console.assert(res === 6); 03 04 res = sum3([1, 5, 0, 5]); 05 console.assert(res === 6); Which two results occur when running this test on the updated sum3 function? Choose 2 answers. The line 05 assertion passes. The line 02 assertion fails. The line 05 assertion fails. The line 02 assertion passes.

132.)Given the following code: let counter = 0; const logCounter = () => { console.log(counter); }; logCounter(); setTimeout(logCounter, 1100); setInterval(() => { counter++ logCounter(); }, 1000); What is logged by the first four log statements?. 0 1 1 2. 0 1 2 3. 0 0 1 2. 0 1 2 2.

133.) Refer to the code below: async function functionUnderTest(isOK) { if(isOK) return 'OK' ; throw new Error('not OK'); } Which assertion accurately tests the above code?. Console.assert (await functionUnderTest(true), 'OK'). Console.assert (await functionUnderTest(true), ' notOK '). Console.assert (await functionUnderTest(true), ' not OK '). Console.assert (await functionUnderTest(true), ' OK ').

134.) Considering type coercion, what does the following expression evaluate to? true + '13' + NaN. ' true13NaN '. ' true13 '. 14. ' 113Nan '.

A developer creates an object where its properties should be immutable and prevent properties from being added or modified. Which method shouldbe used to execute this business requirement ?. Object.freeze(). Object.lock(). Object.const(). Object.eval().

Which function should a developer use to repeatedly execute code at a fixed interval?. setInterval. setTimeout. setInteria. setPeriod.

A developer at Universal Containers creates a new landing page based on HTML, CSS, and JavaScript to ensure that visitors have a good experience, a script named personaliseContext needs to be executed when the webpage is fully loaded (HTML content and all related files), in order to do some custom initialization. Which statement should be used to call personalizeWebsiteContent based on the above business requirement?. window.addEventListener('load',personalizeWebsiteContext);. document.addEventListener(''onDOMContextLoaded', personalizeWebsiteContext);. window.addEventListener('onload', personalizeWebsiteContext);. Document.addEventListener('''DOMContextLoaded' , personalizeWebsiteContext);.

Refer to code below: const objBook = { title: 'Javascript', }; object.preventExtensions(objBook); const newObjBook = objBook; newObjBook.author = 'Robert'; What are the values of objBook and newObjBook respectively?. { title: "javaScript" } { title: "javaScript" }. { author: "Robert", title: "javaScript" } Undefined. { author: "Robert", title: "javaScript" } { author: "Robert", title: "javaScript" }. { author: "Robert" } { author: "Robert", title: "javaScript" }.

Which option is true about the strict mode in imported modules?. Imported modules are in strict mode whether you declare them as such or not. Add the statement use strict = false; before any other statements in the module to enable not- strict mode. You can only reference notStrict() functions from the imported module. Add the statement use non-strict, before any other statements in the module to enable not-strict mode.

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?. 5. Nan. 10. Undefined.

Refer to the following object: const cat ={ firstName: 'Fancy', lastName: 'Whiskers', get fullName() { return this.firstName + ' ' + this.lastName; } }; How can a developer access the fullName property for cat?. cat.fullName. cat.fullName(). cat.get.fullName. cat.function.fullName().

A team that works on a big project uses npm to deal with projects dependencies. A developer added a dependency does not get downloaded when they execute npm install.Which two reasons could be possible explanations for this? Choose 2 answers. The developer added the dependency as a dev dependency, and NODE_ENV is set to production. The developer missed the option --save when adding the dependency. The developer missed the option --add when adding the dependency.

At Universal Containers, every team has its own way of copying JavaScript objects. The code Snippet shows an implementation from one team: function Person() { this.firstName = "John"; this.lastName = 'Doe'; this.name = () => ( console.log('Hello $(this.firstName) $(this.firstName)'); ) } const john = new Person (); const dan = JSON.parse(JSON.stringify(john)); dan.firstName = 'Dan'; dan.name(); What is the Output of the code execution?. TypeError: dan.name is not a function. Hello Dan Doe. Hello John DOe. TypeError: Assignment to constant variable.

Refer to the code below: new Promise((resolve, reject) => { const fraction = Math.random(); if( fraction >0.5) reject("fraction > 0.5, " + fraction); resolve(fraction); }) .then(() => console.log("resolved")) .catch((error) => console.error(error)) .finally(() => console.log(" when am I called?")); When does Promise.finally on line 08 get called?. When resolved or rejected. WHen resolved. When resolved and settled. When rejected.

Which three browser specific APIs are available for developers to persist data between page loads ? Choose 3 answers. Cookies. localStorage. indexedDB. Global variables. IIFEs.

A developer creates a generic function to log custom messages in the console. To do this, the function below is implemented. 01 function logStatus(status) { 02 console./*Answer goes here*/{'Item status is: %s', status}; 03 } Which three console logging methods allow the use of string substitution in line 02?. Log. Info. Error. Message. Assert.

Refer to the code below: let​ greeting = "​Goodbye"​; let​ salutation = ​"Hello, hello, hello"​; try​ { greeting = "​Hello"​; decodeURI("​%%%"​);​ // throws error salutation = ​"Goodbye"​; }​ catch​ (err) { salutation = ​"I say hello";​ }​ finally​ { salutation = ​" Hello, hello";​ } Line 05 causes an error.What are the values of greeting and salutation once code completes? A. Greeting is Hello and salutation is Hello, Hello. sadf. asdf.

developer creates a new web server that uses Node.js. It imports aserver library thatuses events and callbacks for handling server functionality.The server library is imported with require and is made available to the code by avariable named server. The developer wants to log any issues that the server has while booting up. Given the code and the information the developer has, which code logs an error at boost with an event?. server.on('error', (error) => { console.log('ERROR', error); });. server.error ((server) => { console.log('ERROR', error); });. server.catch ((server) => { console.log('ERROR', error); });. try { server.start(); } catch(error) { console.log('ERROR', error); }.

Question #:147 A developer is creating a simple webpage with a button. When a user clicks this button for the first time, a message is displayed.The developer wrote the JavaScript code below, but something is missing. The message gets displayed every time a user clicks the button, instead of just the first time. 01 function listen(event) { 02 alert ( 'Hey! I am John Doe'); 03 button.addEventListener ('click', listen); Which two code lines make this code work as required? Choose 2 answers A. On line 02, use event.first to test if it is the first execution. B. On line 04, use event.stopPropagation ( ), C. On line 04, use button.removeEventListener(' click" , listen); D. On line 06, add an option called once to button.addEventListener(). a. sadf.

Report abuse