bartleby
search
close search
Hit Return to see all results

Hello, I have a question with the program javascript and in the program I need to create a timer in which it will give me good morning from midnight till noon, good afternoon, noon till 5pm, and good evening from 5pm till midnight. The is I have so far in the webstorm text editor: // hello.js// This is a client-side JavaScript program that tells the time.// It is meant to be embeded in a web page named "hello.html".var today = new Date()var curHr = today.getHours()if (curHr < 12) {console.log('good morning')} else if (curHr < 18) {console.log('good afternoon')} else {console.log('good evening')}function displayHello() {document.getElementById("displayArea").innerHTML= curHr + " Current time is: " + new Date();}Sorry I couldn't upload the attachment for some reason. I appreciate it though.

Question

Hello, I have a question with the program javascript and in the program I need to create a timer in which it will give me good morning from midnight till noon, good afternoon, noon till 5pm, and good evening from 5pm till midnight. The is I have so far in the webstorm text editor: // hello.js
// This is a client-side JavaScript program that tells the time.
// It is meant to be embeded in a web page named "hello.html".
var today = new Date()
var curHr = today.getHours()

if (curHr < 12) {
console.log('good morning')
} else if (curHr < 18) {
console.log('good afternoon')
} else {
console.log('good evening')
}
function displayHello() {
document.getElementById("displayArea").innerHTML= curHr + " Current time is: " + new Date();
}
Sorry I couldn't upload the attachment for some reason. I appreciate it though.

check_circleAnswer
Step 1

To display the greeting message, we can declare a new variable, suppose wish, to store the greeting message and using label tag in HTML, we can call the JavaScript function. Let us understand the process as follows:

Note: We will use the <script> tag to demonstrate the procedure.

There’s more to the solution above. Sign up now to see!

Sign Up

Not ready to register yet? Check out a sample Q&A here.

Stuck on your homework?

Get expertly curated answers to your homework questions for just $9.99/month

Get As ASAP
Tagged in

Engineering

Computer Science

Sorry about that. What wasn’t helpful?