Asynchronous

Report a typo

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.

Sample Input 1:

Sample Output 1:

16
Write a program in JavaScript
// Write code below this line

...function squareNumber(number) {
...
}

squareNumber(4)
.then((result) => {
...

// Write code above this line
___

Create a free account to access the full topic