O'Reilly logo

React Native By Example by Richard Kho

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Date methods

These are the things that the dateMethods.js file should contain:

  • An object that maps the number of the month to its name
  • Four methods get different parts of the date. Each should accept an optional date object or create a new instance of the Date object if one is not passed in the following ones:
    • getYear: This grabs the year number and returns a stringified form of it
    • getMonth: This grabs the month number and returns a stringified form of it
    • getDay: This grabs the day number and returns a stringified form of it
    • getMonthString: This returns the name of the month using the object created previously

This is how my dateMethods file looks after completing the preceding bullet points. This is an object mapping month numbers to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required