Complete the squareNumber function, which has to be asynchronous. It returns a promise that resolves to a square of the given number. You need to log the final result (the square of a number), then similarly log an error in case the promise is rejected.
Async/await
Asynchronous
Report a typo
Sample Input 1:
Sample Output 1:
16Write a program in JavaScript
// Write code below this line
...function squareNumber(number) {
...
}
squareNumber(4)
.then((result) => {
...
// Write code above this line
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.