function replaceAt(array, index, value) { const ret = array.slice(0); ret[index] = value; return ret; } const newArray = replaceAt(items, index, "J");