Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created April 2, 2017 01:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/8209685e377cbf629240c0d0c0e98c66 to your computer and use it in GitHub Desktop.
Save codecademydev/8209685e377cbf629240c0d0c0e98c66 to your computer and use it in GitHub Desktop.
Codecademy export
function getSleepHours(day)
//begin complete function
{
var hours = prompt ("how many hours of sleep did you get on " + day + " of the week?");
return(Number(hours));
function getActualSleepHours()
//function 1
{
return (
getSleepHours ('Monday') +
getSleepHours ('Tuesday') +
getSleepHours ('Wednesday') +
getSleepHours ('Thursday') +
getSleepHours ('Friday') +
getSleepHours ('Saturday') +
getSleepHours ('Sunday'));
}
//end function 1
//function 2
function getIdealSleepHours () {
var idealHours = ("how much sleep is ideal per night?");
return(Number(idealHours)*7);
}
// end function 2
function calculateSleepDept() {
var actualSleepHours = getAcutalSleepHours();
var idealSleepHours = getIdealSleepHours();
if (acutalSleepHours === idealSleepHours) {console.log ( "You got enough rest.");}
if (actualSleepHours > idealSleepHours);
{console.log( "You were tired, and got " + (actualSleepHours- idealSleepHours) + " more then you wanted!");}
if (actualSleepHours < idealSleepHours);
{console.log( "You got " + (idealSleepHours - actualSleepHours) + " hours less than you needed. Get more rest.");}
}
//end function 3
//end complete function
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment