Javascript Bytes (7): Number of seconds till midnight

We want to make a function that takes in two integers as arguments and returns the amount of seconds left in the day.

 

function secondsTillMidnight(hour, minute) {

var minToSec = minute * 60;
var hoursToSec = hour * 60 * 60;
var midnight = 60 * 60 * 24;
console.log(midnight);

return midnight – (minToSec + hoursToSec);

}

secondsTillMidnight(9, 21);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s