How to create a reusuable modal?

I would like to create a generic Modal for different confirmations/errors and or infos.
How would I be able to create a modal that can be initialized with some text and the calling method respond to the boolean result there of.
Similar to :
if (confirm(“Are you sure?”))
//do something
//do something else

Hey! This can be done by using JS async-await and storeValue functions.
Steps -

  1. Create an async function
  2. Store the confirmation message in store using await storeValue(...) syntax
  3. Open modal at last
  4. In your modal use the stored message value to show the confirmation text
  5. Create a function to conditionally trigger the relevant actions from modal