Javascript Developer 1 Cert

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

A developer wants to set up 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 the to index.js to create the secure web server? A. const https = require('https'); B. const server = require('secure-server'); C. const http = require('http'); D. const tls = require('tls');

A

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? A. 16 B. 11 C. 36 D. 25

A

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. function listen(event) { alert('Hey ! I am John Doe'); } button.addEventListener('click', listen) Which two code lines make this code work as required? Choose 2 answers A. On line 04, use button.removeEventListener('click', listen); B. On line 02, use event.first to test if it is the first execution C. On line 06, add an option called once to button.addEventListener(); D. On line 04, use event.stopPropagation();

A C

const exec = (item, delay) => new Promise(resolve => setTimeout(() => resolve(item), delay)); async function runParallel() { const result1, result2, result3 = await Promise.all( exec('x', '100'), exec('y', '500'), exec('z', '100') ); return 'parallel is done: ${result1}${result2}${result3}'; } which two statements correctly execute the runParallel() function?choose 2 answers A. runParallel().then(function(data) { return data; }); B. runParallel().done(function(data) { return data; }); C. runParallel().then(data); D. async runParallel().then(data);

A C

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

A C

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

A C D

A developer needs to debug a Node.js web server because a runtime error keeps occuring at one of the endpoints. The developer wants to test the endpoint on a local machine and make the request against a local server to look at the behavior. In the source code, the server.js file will start the server. The developer wants to debug the Node.js server only using the terminal. Which command can the developer use the open the CLI debugger in their current terminal window? A. node -i server.js B. node inspect server.js C. node start inspect server.js D. node server.js --inspect

B

A developer tries to retrieve all cookies, then sets a certain key value pair in the cookie. These statements are used: document.cookie; document.cookie = 'key=John Smith'; What is the behavior? A. Cookies are read, but the key value is not set because the value is not URL encoded B. Cookies are read and the key value is set, the remaining cookies are unaffected C. Cookies are read and the key value is set, and all cookies are wiped D. Cookies are not read because line 01 should be document.cookies, but the key value is set and all cookies are wiped

B

Given the following code: let x = ('15' + 10) * 2 What is the value of x? A. 50 B. 3020 C. 1520 D. 35

B

Given the following code:let x = null;console.log(typeof x); what is the output of line 2? A. undefined B. object C. null D. x

B

The 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". const sayHellow = (name) => {console.log('Hello ', name);}; const world = () => {return 'World';}; sayHello(world); What can the developer do to change the code to print "Hello World"? A. Change line 7 to ) (); B. Change line 2 to console.log('Hello', name()); C. Change line 9 to sayHello(world)(); D. Change line 5 to function world() (

B

which statement parses successfully? A. JSON.parse('foo'); B. JSON.parse(' "foo" '); C. JSON.parse(" 'foo' "); D. JSON.parse("foo");

B

splice(start, deleteCount, item1)

delete count removes backward, item is added forward

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? A. printPrice must be named export B. printPrice must be a multi export C. printPrice must be the default export D. printPrice must be an all export

C

Remove all ads <!-- This is an add --><div class="ad-library-item ad-hidden" onload="myFunction()"><img src="/ad-library/ad01.gif"/></div> All the elements include 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? A. Use the DOM inspector to remove all the elements containing the class ad-library-item B. Use the DOM inspector to prevent the load event to be fire C. Use the browser console to execute a script that removes all the elements containing the class ad-library-item D. Use the browser console to execute a script that prevents the load event to be fired

C

Refer to the string below: const str = 'Salesforce'; Which two statements result in the word 'Sales'? Choose 2 answers A. str.substring(1, 5); B. str.substr(1, 5); C. str.substring(0, 5); D. str.substr(0, 5);

C D

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? A. On the terminal console running the web server B. On the webpage console log C. In the browser performance tools log D. On the browser JavaScript console

D

A 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? A. True negative B. True positive C. False positive D. False negative

D

Refer to the code below: const pi = 3.1415926; What is the data type of pi? A. Float B. Decimal C. Double D. Number

D


Set pelajaran terkait

Chapter 13 mastering biology assignment

View Set

08-03-04 Dictionaries - dctionary-traversal

View Set

Texas Pre-License - Promulgated Contracts

View Set

Mental Health - Chapter 1 - Mental Health and Mental Illness

View Set

True or False Communism activity

View Set

Anatomy 231 Chapter 9 joints study guide

View Set