-
-
Save codecademydev/8209685e377cbf629240c0d0c0e98c66 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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