0% found this document useful (0 votes)
14 views4 pages

Prism - AI Driven Full Stack Digital Learning Experience Platform2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views4 pages

Prism - AI Driven Full Stack Digital Learning Experience Platform2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

3/1/23, 12:51 AM Prism - AI driven, full stack digital learning experience platform

Data Types & Structures Modules and Package Managers


Rows per page: 10 11-20 of 2
View all strengths View all Areas of Development

Contact Support Terms Privacy Program Policies Powered by Knowledgehut


Detail Report

Dashboard
What will be the output of the following code? Asynchronous JavaScript 2/2
Courses
function getGreeting() { return new Promise((resolve) => {

Sessions setTimeout(() => resolve('Good Morning!'), 2000); }); }


function fetchData() { let data = await getGreeting();
console.log(data); } fetchData();
Assessments

'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

function numOne() { return new Promise((resolve) => {


setTimeout(() => resolve(20), 1000); }); } function
numTwo() { return new Promise((resolve) => {
setTimeout(() => resolve(40), 1000); }); } (async function
main() { let one = await numOne(); let two = await
numTwo(); console.log(one, two); })();

20 40

NaN

Nothing is shown on the console

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.

What is not true about generator functions? Asynchronous JavaScript 2/2

They produce new functions whenever executed

They can be paused and resumed

They can be declared by placing an asterisk after the function keyword

They can return multiple values over the course of execution

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

Errors are automatically managed


Bookmarks

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

function* getData(x, y) { yield x / y; yield x * y; } let


processNum = getData(23, 45); processNum.next();
console.log(processNum.next().value);

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

JavaScript language standard

Web APIs

Network APIs

None of the listed

Reason
The XMLHttpRequest object is a part of the Web APIs the browser provides for working with network requests.

What is the meaning of Idempotency? Working with Remote Data a… 3/3

It means that content must always be sent in a POST or PATCH request to the server

It refers to the use of query parameters that can be bookmarked

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

None of the listed

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

Social learning POST

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)

const apiUrl = '//api.briansapp.com'; const xhr = new


XMLHttpRequest(); xhr.addEventListener('load', function () {
app.innerHTML = this.responseText; });
____________________________

xhr.exec('GET');

xhr.open(apiUrl);

xhr.send();

xhr.open('GET', apiUrl);

xhr.send();

None of the listed

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

You might also like