Итак, с помощью Нины Шольц и Друга я получил правильный ответ:
Начальный массив:
["1", "1", "1", "1", "1", "2", "0", "0"]
Требуемый массив:
["1", "1", "1", "1", "2", "3", "4", "0"]
Функция:
isSibling() {
const siblings = this.props.data.map(item => (
item.progress
));
let i;
const place = '3';
for (i = 0; i < siblings.length; i++) {
if (siblings[i] === '2') {
const num = i;
siblings[i] = place;
this.update(siblings, i - 1, '2');
this.update(siblings, i + 1, '4');
return siblings;
}
}
return siblings;
}
Функция обновления:
чтобы убедиться, что массив не удлинен и не укорочен:
update(array, index, value) {
if (index >= 0 && index < array.length) {
array[index] = value;
}
}
Спасибо за вашу помощь! : D