Write a function named mergeIntervals
that receives 2 parameters:
an Array of objects representing intervals of numbers - intervals
. Each object has the following props:
from
: the smallest number in the intervalto
: the biggest number in the intervalnumbers
: an Array of numbers in ascending order. All numbers are between from
and to
(inclusive).The intervals are non-overlapping and sorted ascending based on the from
prop.
another Array of intervals following the same structure - newIntervals
The function should merge both intervals into one and return it. It's important that the returned interval Array follows the same rules as the parameter ones.
intervals
=newIntervals
=