JS Date Object
JS logic & basics
JS DOM & events
EXP:
40

JS Date Object

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.

INSTRUCTIONS

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



    - Final (whatever the date will be on the day you write the code)

    React



Evaluation
  • After submission, your solution will be evaluated automatically based on the tasks defined above.
  • Upon successful completion of all the tasks/requirements, you will get a full score, and there will not be any partial scoring.
  • You can work on your failed test cases & resubmit your solution.
  • Your problem will get evaluated instantly.

Do’s & don’t
  • Use the given code structure in editor and do not make any changes.
  • Do not modify existing classes or tags.
  • Focus on correct HTML structure and class names.

Query & feedback
  • In case of any query/feedback on this project, please fill this form & we will soon get in touch with you to resolve.

Best of luck, developers!