JSFiddle - React, Tailwind, and code Playground

HTML

<div id="base">
    <div id="c1"></div>
    <div id="c2" class="remove"></div>
    <div id="c3"></div>
    <div id="c4"></div>
</div>

<textarea id="log" rows=15 cols=60></textarea>

JavaScript

var gLog = document.getElementById("log");
function log() {
    gLog.value += Array.prototype.join.call(arguments, ",") + "\n";
}

var b = ["c1", "c2", "c3", "c4"]; 
for (var c of b) {
    log("Testing", c);
    if (c == "c2") {
        log("Removing", c);
        b.splice(b.indexOf(c), 1)
    }
}