NodeJS setInterval() running parallel to loop using async [duplicate]

I have two functions

  1. console.log() running every second, using setInterval()
  2. a constant loop calculating (eg. repeatedly calculating sha256)

Using asynchronous JavaScript, how can I run both a constant loop and still console.log() every second.

Everything I’ve tried brought no solution, as the calculating loop always goes to the top of JavaScript’s queue and runs until it I manually stop this loop and then the interval starts going every second

I know that a solution also involves Web Workers, but I would rather like to understand this first.