Created
July 24, 2017 00:00
-
-
Save LindseyCason/23846588548a2e02158566ea51045c3b to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/qevayu
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
/*Control flow: | |
Control flow is the order in which the computer executes | |
a block of code in a function. IF a condition is met (true) a certain line of code | |
will execute. If the condition is not met (false), | |
the next condition will be evaluated and will be indicated by 'else if'. | |
If the 'else if' condition is not true the 'else' code will run. | |
You can have many 'else if' statements chained together. The code will execute | |
at the first true | |
ex. */ | |
function myTime(hour) { | |
if (hour < 1200) { | |
return "Good Morning!" ; | |
} else if (hour < 1600) { | |
return "Good Afternoon!"; | |
} else if (hour < 2000) { | |
return "Good Evening!"; | |
} else { | |
return "Good Night!"; | |
}} | |
console.log(myTime(1100)); // "Good Morning!" | |
console.log(myTime(1205)); // "Good Afternoon!" | |
console.log(myTime(1632)); // "Good Evening!" | |
console.log(myTime(2052)); // "Good Night!" | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">/*Control flow: | |
Control flow is the order in which the computer executes | |
a block of code in a function. IF a condition is met (true) a certain line of code | |
will execute. If the condition is not met (false), | |
the next condition will be evaluated and will be indicated by 'else if'. | |
If the 'else if' condition is not true the 'else' code will run. | |
You can have many 'else if' statements chained together. The code will execute | |
at the first true | |
ex. */ | |
function myTime(hour) { | |
if (hour < 1200) { | |
return "Good Morning!" ; | |
} else if (hour < 1600) { | |
return "Good Afternoon!"; | |
} else if (hour < 2000) { | |
return "Good Evening!"; | |
} else { | |
return "Good Night!"; | |
}} | |
console.log(myTime(1100)); // "Good Morning!" | |
console.log(myTime(1205)); // "Good Afternoon!" | |
console.log(myTime(1632)); // "Good Evening!" | |
console.log(myTime(2052)); // "Good Night!" | |
</script></body> | |
</html> |
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
/*Control flow: | |
Control flow is the order in which the computer executes | |
a block of code in a function. IF a condition is met (true) a certain line of code | |
will execute. If the condition is not met (false), | |
the next condition will be evaluated and will be indicated by 'else if'. | |
If the 'else if' condition is not true the 'else' code will run. | |
You can have many 'else if' statements chained together. The code will execute | |
at the first true | |
ex. */ | |
function myTime(hour) { | |
if (hour < 1200) { | |
return "Good Morning!" ; | |
} else if (hour < 1600) { | |
return "Good Afternoon!"; | |
} else if (hour < 2000) { | |
return "Good Evening!"; | |
} else { | |
return "Good Night!"; | |
}} | |
console.log(myTime(1100)); // "Good Morning!" | |
console.log(myTime(1205)); // "Good Afternoon!" | |
console.log(myTime(1632)); // "Good Evening!" | |
console.log(myTime(2052)); // "Good Night!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment