https://js-beginners.github.io/greeting-message-project/ (Hosted on Github)
It extracts the hour from the Date() object, and using the the local time it writes a message with your name.
The message is “Good morning, Good afternoon, or Good evening” depending on the time.
It also uses the
document.prompt() method to retrieve the user's name.
- Date() Object
- Control Flow
My Personalize Summary
Just like the previous project, this project was pretty simple.
But, I did learn something new while watching the instructor's solution.
Since the solution was so short, I figured I'd check it out.
Come to find out, there was a bit of information that I learned after seeing him use the
I never used it before so I did some research to find what it was all about.
New Things Learned or Refreshed
It turns out the
document.write() is a quick way to write a output message directly into your HTML document.
Document.write() Definition and Usage
The write() method is mostly used for testing: If it is used after an HTML document is fully loaded, it will delete all existing HTML.
Note: When this method is not used for testing, it is often used to write some text to an output stream opened by the document.open() method.
Tip: The document.writeln() method is similar to write(), only it adds a newline character after each statement.
So, for quick testing, instead of creating a DOM element with
document.createElement() and then appending the element to a DOM node, you can just use
document.write() to add content to the browser.
The other thing I learned was that the Window.prompt() method actually takes a default value, like so:
Time to Code
This project took me about ten minutes to code, including the HTML and CSS.
What To Accomplish
- Download the source code from the github repository above.
- Delete the contents of the
- Add a link to your finished project below!
What You Should See