JSFiddle - React, Tailwind, and code Playground

by Justin Herter

JavaScript

// say you have an array of projects you need to add.
var arrayOfProjects = [{name: "project1"}, {name: "project2"}, {name: "project3"}];

// This takes the first project off of the array and assigns it to "next" leaving the remaining items on the array.

var nextProject = function (array) {

    // if there are items left then do work. Otherwise done.
    if (array.length > 0) {
        // shift the item off of the array and onto "next"
        var next = array.shift();

        addNewProject(next);

    }

} 
var addNewProject = function (project) {
    // Do stuff with the project
    console.log("project name: ", project.name);
    // When complete start over
    nextProject(arrayOfProjects);
}

// Start the process
nextProject(arrayOfProjects);