day_04/guardMostFrequestAsleepCalculation.js
/**
 * Function will take the timestamp from the log, and
 * parse it into a JS date.
 *
 * Log example: [1518-11-09 23:58] Guard #853 begins shift
 * Returns:     1518-11-09T23:58:00.000Z
 *
 * @param {string} log string containing a timestamp inside brackets
 * @returns {Date} date based on the timestamp
 */
Function will take the timestamp from the log, and
parse it into a JS date.



@param {string} log string containing a timestamp inside brackets
@returns {Date} date based on the timestamp
Function will take the timestamp from the log and parse it into a JS date . @param { string } log string containing a timestamp inside brackets @returns { Date } date based on the timestamp
function parseDateFromLog (log) {
  const timestampStart = log.indexOf('[')
  const timestampStop = log.indexOf(']')
  const timestampString = log.slice(timestampStart + 1, timestampStop)
  const isoDateString = timestampString.replace(' ', 'T') + ':00.000Z'
  const date = new Date(isoDateString)
  return date
}
function parseDateFromLog ( log ) { const timestampStart = log . indexOf ( '[' ) const timestampStop = log . indexOf ( ']' ) const timestampString = log . slice ( timestampStart + 1 , timestampStop ) const isoDateString = timestampString . replace ( ' ' , 'T' ) + ':00.000Z' const date = new Date ( isoDateString ) return date }
Function will take the timestamp from the log, and
 parse it into a JS date.
Function will take the timestamp from the log and parse it into a JS date .