Split a time range into pieces by other time ranges in javascript

I have a time range, for example: 14:30:00 until 18:30:00. Consider this time range somebody’s work shift. During this time range, they state they cannot work from 15:30:00 until 16:30:00 and from 17:30:00 until 18:30:00. var obj = { startTime: 14:30, endTime: 18:30 } var deviation = [{s:15:30,e:16:30},{s:17:30,e:18:30}] So i need output like [{s:14:30 ,e:15:30},…

Javascript regex replace in-string variable with actual variable value

I would like “category/[categoryName]/all” to become “category/movies/all” (replace “[categoryName]” with the value of the variable with the same name). I have this so far but I’m missing something: let categoryName = “movies”; // example variable, set somewhere else … let searchUrl = “category/[categoryName]/all”; // Set dynamically, not always categoryName let regex = /\[(.+?)\]/ug; searchUrl =…