Skip to content

Instantly share code, notes, and snippets.

@S4WA
Last active November 5, 2022 07:34
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 S4WA/80b804fb5972e6bc1db0fe90017d6f0d to your computer and use it in GitHub Desktop.
Save S4WA/80b804fb5972e6bc1db0fe90017d6f0d to your computer and use it in GitHub Desktop.
console.log( response( new Date().getHours() ) );
var time = 0;
setInterval(function() {
$('#msg').text( response(time) );
console.log(time, $('#msg').text());
time = time + 1;
if (time == 24) {
time = 0;
}
}, 1000);
function response(time) {
return ( time >= 0 && time < 5 ) ? 'こんばんは' : ( ( time >= 5 && time < 11 ) ? 'おはようございます' : ( time >= 11 && time < 16 ) ? 'こんにちは' : 'こんばんは' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment