I used flat in one of the problems and it would throw an error saying:
"flat() is not a function". I tried to execute the same code on jsBin and it would work. Therefore I assume LeetCode doesn't support flat() yet?
This is the function:
/**
* @param {number[][]} intervals
* @return {boolean}
*/
var canAttendMeetings = function(intervals) {
return intervals.sort((a,b) => a[0] - b[0])
.flat()
.every((x,i, src) => {
return i % 2 === 0 || src[i + 1] === void 0 || src[i] < src[i + 1];
});
};
let Input = [[0,3],[5,10],[15,20]];
//Input = [[7,10],[2,8]];
console.log(canAttendMeetings(Input));This was the task:
https://leetcode.com/problems/meeting-rooms/