Unlocking promise methods in JavaScript

Report a typo
Hey there! This problem might be a bit unpredictable, but give it a go and let us know how you do!
Consider the following JavaScript code snippet. The 'then', 'catch', and 'finally' keywords are used for promise chaining. What are their exact roles in the chaining process and what order will they be executed in?

let dataFetch = new Promise((resolve, reject) => {
  setTimeout(() => {
    if(Math.random() > 0.5) {
      resolve('Data fetched successfully!');
    } else {
      reject('Data fetching failed!');
    }
  }, 2000);
});

dataFetch
  .then(response => {
    console.log(response);
    return 'Processing data...';
  })
  .then(message => console.log(message))
  .catch(error => console.error(error))
  .finally(() => console.log('Operation Complete'));
Select one option from the list
___

Create a free account to access the full topic