Grouping, merging and mapping with a timetable
A review mostly focusing on style:


Avoid calls to console.log in clean code (it's okay for debugging, but should be removed afterwards)
Try not to declare variables in for statements ( the variable is accessible to the whole function anyway). Try to declare variables on top
Your code could use more comments, especially this part which was hardest to parse/grok:

     if (arr[i] - ranges[lastIndex][1] === 1) {
         ranges[lastIndex][1] = arr[i];
     } else {
         ranges[++lastIndex] = [arr[i], arr[i]];
     }



Other than that there is not much wrong with the code, I tried to write it in a more elegant way, but found my attempts usually longer and not that much more elegant.