September 18th, 2024
What's missing in this code?
func([1800, 4500, 1800]); // true
func([3660, 4500, 3600]); // false
func([7200, 2570, 3600]); // true
function func(arr) {
const convert = (sec) => {
const h = Math.floor(sec / 3600);
const m = Math.floor((sec % 3600) / 60);
return `${String(h).
(2, '0')}:${String(
m
).padStart(2, '0')}`;
};
const times = arr.map(convert);
const mins = times.map((time) =>
Number(
)
);
const hasIt = mins.some(
(_, i, arr) =>
i < arr.length - 2 &&
arr[i] === arr[
] &&
arr[i] !== arr[
]
);
return hasIt;
}
Type or select from these options