# [JavaScript] Numbers, Dates, Intl, and Timers - Timers: setTimeout and setInterval

```
// Set Timeout
const ingredients = ['olives', 'spinach'];
const pizzaTimer = setTimeout(
  (ing1, ing2) => console.log(`Here is your pizza with ${ing1} and ${ing2} 🍕`),
  3000, // 1s =1000 ms
  ...ingredients
);
console.log('Waiting... (after 3 seconds later)');

if (ingredients.includes('spinach')) clearTimeout(pizzaTimer);
```

- no pizza...
![setTimeout 1.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1658173426602/Af0D3il3r.PNG align="left")


```
const ingredients = ['olives', ''];
const pizzaTimer = setTimeout(
  (ing1, ing2) => console.log(`Here is your pizza with ${ing1} and ${ing2} 🍕`),
  3000, // 1s =1000 ms
  ...ingredients
);
console.log('Waiting... (after 3 seconds later)');

if (ingredients.includes('spinach')) clearTimeout(pizzaTimer);
```
- pizza with olives

![setTimeout 2.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1658173507430/KlDlD3TAM.PNG align="left")

```
// Set Interval
setInterval(function () {
  const now = new Date();
  console.log(now);
}, 1000);
```

![setInterval 1.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1658173593840/QiI1Pzf76.PNG align="left")

```
// clock formatting
setInterval(function () {
  const now = new Date();
  const hour = now.getHours();
  const min = now.getMinutes();
  const sec = now.getSeconds();
  console.log(`${hour}:${min}:${sec}`);
}, 1000);
```

![setInterval 2.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1658173684219/oKuG0Y43j.PNG align="left")

```
// applying to the app
// Add movement with delay(approvement)
 setTimeout(function () {
      currentAccount.movements.push(amount);
      console.log('2.5 seconds later'); // only for checking setTimeout worked well...
      // add loan date
      currentAccount.movementsDates.push(new Date().toISOString());

      // Update UI
      updateUI(currentAccount);
    }, 2500);
```


![loan delay 1.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1658173888375/wsh7ncBfU.PNG align="left")

![loan delay 2.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1658174102413/WskEPHA5A.PNG align="left")

