resolveWithValue() practice question!

Hello! Can anyone help solve this quiz question? I have been stuck for two days now!

Write a function resolveWithValue() that has two parameters:

  • The first parameter is a function that returns a promise.
  • The second parameter is a string value.

When called, resolveWithValue() should invoke the function argument with the string argument and then log the resultant promise’s resolve value or reject reason to the console.

They provide this code:

let testerFunc = (str) => {
if (Math.random() < .5){
return Promise.resolve(Resolved with: ${str})
} else {
return Promise.reject(Rejected with: ${str})
}
}

Thanks!

Provided link:

https://www.codecademy.com/practice/tracks/introduction-to-javascript/modules/javascript-promises?redirect_url=%2Flearn%2Fintroduction-to-javascript

2 Likes