0
0
Javascriptprogramming~10 mins

Async function syntax in Javascript - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare an async function named fetchData.

Javascript
async function [1]() {
  return 'data';
}
Drag options to blanks, or click blank then click option'
AgetData
BfetchData
CloadData
DretrieveData
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different function name than requested.
Forgetting to write the function name after async function.
2fill in blank
medium

Complete the code to declare an async arrow function assigned to fetchData.

Javascript
const fetchData = [1] () => {
  return 'data';
};
Drag options to blanks, or click blank then click option'
Aasync
Bawait
Cfunction
Dreturn
Attempts:
3 left
💡 Hint
Common Mistakes
Placing await instead of async before the arrow function.
Using function keyword inside arrow function declaration.
3fill in blank
hard

Fix the error in the async function declaration by completing the code.

Javascript
async [1] fetchData() {
  return 'data';
}
Drag options to blanks, or click blank then click option'
Afunction
Basync
Cconst
Dlet
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the function keyword after async.
Using variable declaration keywords like const or let incorrectly.
4fill in blank
hard

Complete the code to create an async function expression assigned to fetchData.

Javascript
const fetchData = [1] function () {
  return 'data';
};
Drag options to blanks, or click blank then click option'
Aasync
Bawait
D()
Attempts:
3 left
💡 Hint
Common Mistakes
Adding parentheses or other tokens between function and parentheses incorrectly.
Using await instead of async before function.
5fill in blank
hard

Fill all three blanks to create an async method inside an object named api.

Javascript
const api = {
  [1]: async function() {
    return [2];
  },
  [3]() {
    return 'sync';
  }
};
Drag options to blanks, or click blank then click option'
AfetchData
B'async data'
CsyncMethod
DasyncMethod
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing method names or forgetting to use async keyword.
Returning wrong values or missing quotes around strings.