Recreate setInterval behavior using only setTimeout.
Asked in frontend interviews at Meta, Amazon and TikTok