Prism - AI Driven Full Stack Digital Learning Experience Platform2
Prism - AI Driven Full Stack Digital Learning Experience Platform2
Dashboard
What will be the output of the following code? Asynchronous JavaScript 2/2
Courses
function getGreeting() { return new Promise((resolve) => {
'Good Morning!'
Bookmarks
Undefined
Social learning
Discussion
Nothing is shown on the console
Messenger
SyntaxError: Unexpected reserved word 'await'.
Reason
A syntax error would be thrown because the fetchData() function hasn't been declared as an async function while the await keyword has been used inside.
What will be the output of the following code? Asynchronous JavaScript 2/2
20 40
NaN
20
Reason
The numbers 20 and 40 would be shown on the console because you are using the await keyword on two functions that return promises. Once both are
resolved, you will see the output on the console.
Reason
https://prism.knowledgehut.com/learner/program-detail/62e3ba9069d8461d65a97de0/milestone/reports 2/5
3/1/23, 12:51 AM Prism - AI driven, full stack digital learning experience platform
Generator functions can be paused and resumed and can return multiple values (using yield) over the course of execution. They are declared by using the
'function*' notation.
When using async and await, how are exceptions handled? Asynchronous JavaScript 2/2
Dashboard
By using the .catch() function
Courses
By using a try-and-catch block
Sessions
Using console.error()
Assessments
Social learning
Reason
Errors are managed using a try-and-catch block when using async and await.
Discussion
Messenger
What will be the output of the following code? Asynchronous JavaScript 2/2
0.51
1035
NaN
Undefined
Reason
In this case, the next() is called twice on the generator function, and console.log() is set to output the value from the second yield only, where x * y will result
in 1035.
The XMLHttpRequest object is part of the __________________. (Fill in the blanks) Working with Remote Data a… 1/1
Web APIs
Network APIs
Reason
The XMLHttpRequest object is a part of the Web APIs the browser provides for working with network requests.
It means that content must always be sent in a POST or PATCH request to the server
https://prism.knowledgehut.com/learner/program-detail/62e3ba9069d8461d65a97de0/milestone/reports 3/5
3/1/23, 12:51 AM Prism - AI driven, full stack digital learning experience platform
It means that multiple requests should have the exact same effect
Dashboard
Reason
Idempotency refers to the fact that multiple requests should have the exact same effect on the resource. This is part of the expectations of a PUT request
Courses
handler.
Sessions
Jeremy is building a search feature in his application and has created a form to Working with Remote Data a… 2/2
Assessments
submit the search query. Which HTTP method should he implement in this case?
GET
Bookmarks
Discussion
DELETE
Messenger
PATCH
Reason
Jeremy should implement the GET method, which also happens to be the default HTTP method for a web form. This is because search strings are often
shared or bookmarked. This means the search query should be part of the URL that is sent as a request.
Jeremy is also building a login form to let registered users sign up to maintain their Working with Remote Data a… 2/2
user profiles. Which HTTP method should he implement in this form?
GET
POST
DELETE
PATCH
Reason
Login credentials should never be sent as a part of the URL and must always be sent as a POST request where they travel in the body of the request.
Brian is building an app that uses AJAX to get data from an API using a GET Working with Remote Data a… 2/2
request. His code is shown below. (Fill in the missing bits)
xhr.exec('GET');
xhr.open(apiUrl);
xhr.send();
xhr.open('GET', apiUrl);
xhr.send();
https://prism.knowledgehut.com/learner/program-detail/62e3ba9069d8461d65a97de0/milestone/reports 4/5
3/1/23, 12:51 AM Prism - AI driven, full stack digital learning experience platform
Reason
The xhr.open() method is used to create the request to a URI with a defined HTTP method, and the xhr.send() executes the request.
Dashboard
Rows per page: 10 11-20 of 25
Courses
Sessions
Assessments
Bookmarks
Social learning
Discussion
Messenger
https://prism.knowledgehut.com/learner/program-detail/62e3ba9069d8461d65a97de0/milestone/reports 5/5