JSFiddle - React, Tailwind, and code Playground

by bingjie2680

JavaScript

arr = [1,2,3]

index = 0;
var test = setInterval(function () {
    if(index == 2) 
        clearInterval(test);
    console.log(arr[index++]);
}, 1000);