The new Date().toLocaleDateString() method in JavaScript is used to convert a Date object into a human-readable string format based on the user's locale settings. This method is highly flexible and can be customized to display dates in various formats.
Initial CSS for this problem is already written for you. Your task in this problem is to write javascript inside the script tag and populate the p#date element as per the instructions provided below
| S. no | Problem |
|---|---|
| 1 | populate the p#date element with today's date. |
| Step No. | Step Instruction | Code |
|---|---|---|
| 1 | inside the script tag, store the value of new Date() in any variable. | const today = new Date() |
| 2 | format the date using the toLocaleDateString method on the Date object and store it in a variable | const formattedDate = today.toLocaleDateString() |
| 3 | select the p#date element and populate its textContent with the formatted date | document.getElementById('date').textContent = formattedDate |
Best of luck, developers!