| Exam Name: | Salesforce Certified JavaScript Developer (JS-Dev-101) | ||
| Exam Code: | JavaScript-Developer-I Dumps | ||
| Vendor: | Salesforce | Certification: | Salesforce Developer |
| Questions: | 147 Q&A's | Shared By: | digby |
A developer creates a simple webpage with an input field. When a user enters text and clicks the button, the actual value must be displayed in the console:
HTML:
< input type= " text " value= " Hello " name= " input " >
< button type= " button " > Display < /button >
JavaScript:
01 const button = document.querySelector( ' button ' );
02 button.addEventListener( ' click ' , () = > {
03 const input = document.querySelector( ' input ' );
04 console.log(input.getAttribute( ' value ' ));
05 });
When the user clicks the button, the output is always " Hello " .
What needs to be done to make this code work as expected?
Refer to the code below (assuming Promise.race is intended):
let cat3 = new Promise(resolve = >
setTimeout(resolve, 3000, " Cat 3 completes " )
);
Promise.race([cat1, cat2, cat3])
.then(value = > {
let result = `${value} the race.`;
})
.catch(err = > {
console.log( " Race is cancelled: " , err);
});
(Assuming cat1 and cat2 are similar to earlier examples: cat2 resolves fastest.)
What is the value of result when Promise.race executes?
Refer to the following code block (with corrected template literals using backticks):
01 class Animal {
02 constructor(name) {
03 this.name = name;
04 }
05
06 makeSound() {
07 console.log(`${this.name} is making a sound.`);
08 }
09 }
10
11 class Dog extends Animal {
12 constructor(name) {
13 super(name);
14 this.name = name;
15 }
16 makeSound() {
17 console.log(`${this.name} is barking.`);
18 }
19 }
20
21 let myDog = new Dog( ' Puppy ' );
22 myDog.makeSound();
What is the console output?
A developer is asked to fix some bugs reported by users. To do that, the developer adds a breakpoint for debugging.
01 function Car(maxSpeed, color) {
02 this.maxSpeed = maxSpeed;
03 this.color = color;
04 }
05 let carSpeed = document.getElementById( ' carSpeed ' );
06 debugger;
07 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?