Test
Trudne JSDev1
Crea una cuenta gratis para terminar este test
Guarda tu progreso y consulta tu resultado final.
¿Ya tienes cuenta? Inicia sesión
Preguntas del test (22)
1Refer to the code below:
Which code change should be made for the console to log only Row log when 'Click me!' is clicked?
- AAdd event.removeEventListener(); to printMessage function
- BAdd event.removeEventListener(); to window.onLoad event handler
- CAdd event.stopPropagation(); to window.onLoad event handler
- DAdd event.stopPropagation(); to printMessage function
2Given the code below:
What happens when the code executes?
- AThe url variable has a global scope and line 02 throws an error
- BThe url variable has local scope and line 02 throws an error
- CThe url variable has local scope and line 02 executes correctly
- DThe url variable has a global scope and line 02 executes correctly
3Refer to the code below:
What is the output after the code executes?
- AReferenceError: eyeColor is not defined
- BReferenceError: assignment to undeclared variable "Person"
- Cundefined
- DDeveloper
4A developer is asked to fix some bugs reported by users. To do that, the developer adds a breakpoint for debugging.
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:
- AThe values of the carSpeed and fourWheels variables
- BThe style, event listeners and other attributes applied to the carSpeed DOM element
- CA variable displaying the number of instances created for the Car object
- DThe information stored in the window.localStorage property
5What are two unique features of functions defined with a fat arrow as compared to normal function definition?
Choose 2 answers:- AThe function generates its own this making it useful for separating the function's scope from its enclosing scope
- BThe function receives an argument that is always in scope, called parentThis, which is the enclosing lexical scope
- CIf the function has a single expression in the function body, the expression will be evaluated and implicitly returned
- DThe function uses the this from the enclosing scope
6A developer implements and calls the following code when an application state change occurs:
If the back button is clicked after this method is executed, what can a developer expect?
- AA popstate event is fired with a state property that details the application's last state
- BA navigate event is fired with a state property that details the previous application state
- CThe page is navigated away from and the previous page in the browser's history is loaded
- DThe page reloads and all JavaScript is reinitialized
7Refer to the 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"?- Adocument.getElementById("status").Value = 'Completed';
- Bdocument.getElementById(".status").innerHTML = 'Completed';
- Cdocument.getElementById("status").innerHTML = 'Completed';
- Ddocument.getElementById("#status").innerHTML = 'Completed';
8Given the HTML below:
Which statement adds the priority-account CSS class to the Universal Containers row?
- Adocument.querySelector('#row-uc').classList.add('priority-account');
- Bdocument.querySelector('#row-uc').classes.push('priority-account');
- Cdocument.getElementById('row-uc').addClass('priority-account');
- Ddocument.querySelectorAll('#row-uc').classList.add('priority-account');
9Given the code block below:
What should a developer insert at line 15 to output the following message using the load method?
SNEGeneziz is loading a cartidge game: Super Monic 3x Force...
- AConsole16bit.prototype.load(gamename) {
- BConsole16bit = Object.create(GameConsole.prototype).load = function(gamename) {
- CConsole16bit.prototype.load(gamename) = function() {
- DConsole16bit.prototype.load = function(gamename) {
10Refer to the following code that inports a module named Utils:
Which two implementations of Utils.js export foo and bar such that the code above runs without error?
Choose 2 answers.
- A/

- B,

- C.

- D'

- A/
11Which three statements are true about promises?
Choose 3 answers.- AA settled promise can become resolved
- BThe executor of a new Promise runs automatically
- CA fulfilled or rejected promise will not change states
- DA promise has a .then() method
- EA pending promise can become fulfilled, settled or rejected
12Which three browser specific APIs are available for developers to persist data between page loads?
Choose 3 answers.- AIIFEs
- BIndexedDB
- CGlobal variables
- DCookies
- ElocalStorage
13Refer 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:- Alet x = arr.filter ((a) => (a<2));
- Blet x = arr.splice(2, 3);
- Clet x = arr.slice(2);
- Dlet x = arr.filter((a) => (return a>2));
- Elet x = arr.slice(2, 3);
14A 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 personalizeWebsiteContent 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?- Awindow.addEventListener('onload', personalizeWebsiteContent);
- Bwindow.addEventListener('load', personalizeWebsiteContent);
- Cdocument.addEventListener('DOMContentLoaded', personalizeWebsiteContent);
- Ddocument.addEventListener('onDOMContentLoaded', personalizeWebsiteContent);
15The developer has a function that prints "Hello" to an input name. To test this, the developer created a function that returns "world". However, the following snippet does not print "Hello world".
What can the developer do to change the code to print "Hello World"?
- AChange line 2 to console.log('Hello', name());
- BChange line 7 to }();
- CChange line 5 to function world() {
- DChange line 9 to sayHello(world)();
16Teams at Universal Containers (UC) work on multiple JavaScript projects at the same time. UC is thinking about reuseability 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?- APrivate packages are not supported, but they can use another package manager like yarn
- BPrivate registers are not supported by npm, but packages can be installed via git
- CPrivate packages can be scoped and scopes can be associated to a private registers
- DPrivate registers are not supported by npm, but packages can be installed via URL
17The developer wants to test this code:
const stringifyNumber = (num) => Number(num).toString();
Which two tests are the most accurate for this code?
Choose 2 answers:- Aconsole.assert(stringifyNumber() === 'NaN')
- Bconsole.assert(typeof stringifyNumber(2) === 'string')
- Cconsole.assert(stringifyNumber(-2) === '-2')
- Dconsole.assert(stringifyNumber('') == '0')
18Given the code below:
What is logged to the console?
- A1 4 2 3 5
- B4 2 1 3 5
- C4 2 1 5 3
- D4 5 1 2 3
19A team that works on a big project uses npm to deal with project's dependencies.
A developer added a dependency to manipulate dates and pushed the updates to the remote repository. The rest of the team complaints that the dependency does not get downloaded when they execute npm install.
Which two reasons could be possible explanations for this?
Choose 2 answers.- AThe developer missed the option -add when adding the dependency
- BThe developer missed the option --save when adding the dependency
- CThe developer added the dependency as a dev dependency, and NPM_ENV is set to production
- DThe developer added the dependency as a dev dependency and NODE_ENV is set to production
20Universal 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 the search string change handler.
What are three key steps to implement this debounce function?
Choose 3 answers.- AEnsure that the network request has the property debounce set to true
- BIf there is an existing setTimeout and the search string changes, allow the existing setTimeout to finish and do not require a new setTimeou
- CWhen the search string changes, enqueue the request within a setTimeout
- DStore the timerId of the setTimeout last enqueued by the search string change handler
- EIf 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
21In the browser, the document object is often used to assign variables that require the broadest scope in an application.
Node.js applications do not have access to the document object by default.
Which two methods are used to address this?
Choose 2 answers.- AAssign variables to module.exports and require them as needed
- BUse the window object instead
- CCreate a new document object in the root file
- DAssign variables to the global object
22A developer wants to iterate through an array of 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:
arrObj.reduce((acc, curr) => {
//missing line 02
//missing line 03
}, 0);
Which missing lines 02 and 03 return the correct count?- Aconst sum = curr.startsWith('N') ? 1 : 0;
return acc + sum; - Bconst sum = curr.name.startsWith('N') ? 1 : 0;
return curr + sum; - Cconst sum = curr.startsWith('N') ? 1 : 0;
return curr + sum; - Dconst sum = curr.name.startsWith('N') ? 1 : 0;
return acc + sum;
- Aconst sum = curr.startsWith('N') ? 1 : 0;
Información
- Descripción
- Test sobre Trudne JSDev1, creado por Digir Digir el 19/02/2023.
- Autor
- Digir Digir
- Idioma
- English
- Visitas
- 4
- Historial
- Creado el 19 feb 2023 · actualizado el 19 feb 2023
- Valoración
- Aún sin valoraciones Valora este test