Skip to content

Instantly share code, notes, and snippets.

@omkz
Created February 20, 2012 06:56
Show Gist options
  • Save omkz/1868183 to your computer and use it in GitHub Desktop.
Save omkz/1868183 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,initial-scale=1.0">
<title> Hello Menk </title>
<script type="text/javascript">
// returns the current hour
function GetCurrentHour()
{
// obtaining the current hour
var date = new Date();
var hour = date.getHours();
// return the hour
return hour;
}
function(){
return 20;
}
// display greeting
function DisplayGreeting(hourFunc)
{
// retrieve the hour using the function received as parameter
hour = hourFunc();
// display greeting
if (hour >= 22 || hour <= 5)
document.write("Goodnight, world!");
else
document.write("Morning, world!");
}
</script>
</head>
<body>
<button onclick="DisplayGreeting(GetCurrentHour)">Klik</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment