You should create a Promise when you need to handle an operation that:
Takes time to complete (e.g., fetching data, reading files, or waiting for user input).
Does not return an immediate value but instead will provide the result later.
Should not block the execution of other code.
Can succeed or fail, requiring a way to handle both outcomes.
Normally, a Promise is used to handle asynchronous operations (e.g., fetching data, waiting for a response, or time-consuming tasks).
A new Promise is created, which takes a function with two parameters: rezolva (resolve) and respinge (reject).
Inside the function, pizzaGata is a boolean that determines whether the pizza is successfully made.
setTimeout() is used to simulate a 2-second delay before resolving or rejecting the promise:
If pizzaGata is true, the promise is resolved (rezolva), meaning the pizza is ready.
If pizzaGata is false, the promise is rejected (respinge), simulating an issue (like a broken oven).