JSFiddle - React, Tailwind, and code Playground

by cincodenada

HTML

In: <span id="in"></span><br/>
Out: <span id="out"></span>

CoffeeScript

testarr = ["one","two","three"]
curpos = 2; # This represents some externally-controlled position in the array

invar = []
outvar = []
for index, val of testarr
    if index == curpos
        invar.push(val)
    else
        outvar.push(val)

document.getElementById('in').innerHTML = invar.join(',')
document.getElementById('out').innerHTML = outvar.join(',')