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?
is below: <input type=”file” onchange=”previewFile()”> <img src=”” height=”200” alt=”Image Preview…”/> 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...
Which method should be used to execute this business requirement?
A developer creates an object where its properties should be immutable and prevent properties from being added or modified. Which method should be used to execute this business requirement?A . Object.const()B . Object.eval()C . Object.lock()D . Object.freeze()View AnswerAnswer: D
What is the value of result when Promise.race executes?
Refer to the code below: Let car1 = new Promise((_ , reject) => setTimeout(reject, 2000, “car 1 crashed in” => Let car2 =new Promise(resolve => setTimeout(resolve, 1500, “car 2 completed”) Let car3 =new Promise(resolve => setTimeout(resolve, 3000, “car 3 completed”) Promise.race(( car1, car2, car3)) .then (value => ( Let result...
What is the value of output after the code executes?
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 >0){ Break; } if(num % 2 == 0){ Continue; } Output +=num; What is the value of output after the code...
What are the values of objBook and newObjBook respectively?
Refer to code below: Const objBook = { Title: ‘Javascript’, }; Object.preventExtensions(objBook); Const newObjBook = objBook; newObjectBook.author = ‘Robert’; What are the values of objBook and newObjBook respectively?A . [title: “javaScript”] [title: “javaScript”]B . {author: “Robert”, title: “javaScript} UndefinedC . {author: “Robert”, title: “javaScript} {author: “Robert”, title: “javaScript}D . {author:...
Which code should be inserted at the line 03 to set up an event and start the web server?
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...
Which option makes the code work as expected?
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) => {...
Which two statements could be inserted at line 17 to enable the function call on line 18?
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’); 9 }; 10 11 function Lion(){ 12 this.type = ‘Cat’; 13 this.size = ‘large’; 14 } 15...
Given the code above, which three properties are set pet1?
Refer to the code: Given the code above, which three properties are set pet1? Choose 3 answers:A . NameB . canTalkC . TypeD . OwnerE . SizeView AnswerAnswer: B,C,E
What is the output line 11?
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?A . [1,2]B . [“bar”,”foo”]C . [“foo”,”bar”]D . [“foo:1”,”bar:2”]View AnswerAnswer: C