JavaScript01
根据当前时间显示问候语
var today = new Date(); var hourNow = today.getHours(); var greeting; if (hourNow > 18) { greeting = 'Good evening'; } else if (hourNow > 12) { greeting = 'Good afternoon'; } else if (hourNow > 0) { greeting = 'Good morning'; } else { greeting = 'Welcome'; } document.write(greeting);