Exercise: Computing elapsed minutes

Using the exercise computing minutes to midnight as a starting point (entered in the Web panel for your convenience), create a function that consumesUsed to describe a function taking values as inputs. two date objects for the same day and producesUsed to describe a function returning an output. the number of minutes between the two objects. You can assume that the second object is for a time later than the first object.

You have been provided variables noon and dinner that you can use to see how your function works. The number of elapsed minutes should be 390.

Note:

Hint:

  • Remember to use 24 hour time.

Solution to the exercise

Here is one possible solution. Notice the following:

  • The constant HOURMINS is a local variable, defined inside the function.
  • The constant HOURSOFF has been replaced in the calculation by the parameter hoursTwo.

Note:

Hints:

  • undefined
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
var noon = new Date(1900, 12, 12, 12, 0);
var dinner = new Date(1900, 12, 12, 18, 30);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX