Question: 1
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?
Question: 2
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 ?
Question: 3
The developer wants to test this code:
Const toNumber =(strOrNum) => strOrNum;
Which two tests are most accurate for this code?
Choose 2 answers
Question: 4
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?
Question: 5
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 to make this code work as expected?