You can
can you do it without any browser api
Only Date API
makes sense
Use setTimeout
const ids = new Map(); function setInterval(callback, millis, ...args) { function iterate() { try { callback(...args); } catch (error) { reportError(error); } const nextId = setTimeout(iterate, millis); ids.set(startId, nextId); } const startId = setTimeout(iterate, millis); ids.set(startId, startId); return startId; } function clearInterval(id) { clearTimeout(ids.get(id)); ids.delete(id); }
Why do you assume the engine has setTimeout if it doesn't have setInterval?
Because the exercise only forbid using setInterval.
It's not an exercise
Обсуждают сегодня