<script>
    //filter(current, index, array)
    const movements = [200, 450, -400, 3000, -650, -130, 70, 5000];
    const deposits = movements.filter((mov) =>  mov > 0); //arrow method function
    console.log(deposits);
    const withdraw = movements.filter((mov) => mov < 0);
    console.log(withdraw);

    //reduce(accumulate, current, index, array)
    // 0 is initial value
    //return is no needed to be written
    //Maximum value

    const max = movements.reduce((acc, cur) => {
      if (acc > cur) return acc;
      else return cur;
    }, movements[0]);
    console.log(max);

    const balance = movements.reduce((acc, mov) => acc + mov ,0);
    console.log(balance);*/

    //old way to create array
    const x = [1,2,3,4,5,6,7,8,9];
    console.log(new Array(1,2,3,4,5,6,7,8,9));

    const y = new Array(7); //[empty x 7]
    y.fill(1,3,5);  //[<3 empty slots>,1,1,<2 empty slots>] .fill(which number,from where, to where)
    console.log(y);

    //Array.from
    const z = Array.from({length: 7}, () => 1 );
    console.log(z);

    const random = Array.from({length: 100}, (_, i) => i + 1);
    console.log(random);
    </script>