Convert minute to time for display
I was wondering if there is a better approach to this?


Yes. Use a library. Using what's already done is always better than doing it yourself. ;)

The next best thing you could do is convert minutes into milliseconds and instantiate a Date object from it. From there, JS does most of the heavy lifting for you. Here's an example (not extensively tested, but you get the idea):



const pad = n =&gt; `0${n}`.slice(-2)

const convertMinsToHrsMin = mins =&gt; {
  const date = new Date(mins * 60 * 1000)
  
  // Need to be UTC since timestamps are universal
  // but normal time methods operate based on local time.
  const hours = date.getUTCHours()
  const minutes = date.getUTCMinutes()
  
  // If 0, as in 00:00 or 12:00, default to 12.
  const hours12 = hours % 12 || 12
  const period = hours &gt;= 12 ? 'PM' : 'AM'
  
  return `${pad(hours12)}:${pad(minutes)}${period}`
}

startTime = convertMinsToHrsMin(720);
endTime = convertMinsToHrsMin(1080);

alert(startTime);
alert(endTime);




As for your code:


Use console.log instead of alert. I know alert is a quick way to visualize values, but getting the habit of using console.log will do wonders for your skin.
Avoid very deep and branchy conditionals. if statements don't do anything on its own and has to be mutating some variable. That means you define variables up top. There is a chance that you might miss a branch and leave that variable empty or contain an unwanted value.
Use a ternary for short conditionals, like determining AM and PM. It's short, and gets you into not mutating variables.
Use template literals to construct strings. This way, you don't need to break out strings and you always get a string (not a NaN should your expression fail you due to coercion).
And lastly, get familiar with the native APIs. They do lots of heavy lifting for you so you don't have to write it yourself.