enkryptor

Функция, меняющая исходный массив

Nov 8th, 2023
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function mutate(arr) {
  2.   for (let i = arr.length; i--; i >= 0) {
  3.     if (arr[i].type === 'potato') {
  4.       arr.splice(i, 1);
  5.     } else if (arr[i].type === 'apple') {
  6.       arr[i].price = arr[i].price * 2;
  7.     }
  8.   }
  9. }
Add Comment
Please, Sign In to add comment