I have an array and must fill another one.
Depending of a boolean I copy first or second element and the rest must be as is...
Currently I do it like this (data
has the desired info):
const newArray = [];
newArray[0] = theBoolean ? data[0] : data[1];
for (let i = 2; i < data.length; i += 1) {
newArray[i - 1] = data[i];
}
I've tried with shift and slice but no success...
¿how can I beautify this snippet?
actual URL+"#name"
as stated in comments. Read question and comments carefully, all is there. \$\endgroup\$