Skip to main content
improved formatting
Source Link
palacsint
  • 29.9k
  • 9
  • 81
  • 156
  • You should check if formattedDate is actually a DateDate object before using it (and change the variable name, since it sounds like it contains a formatted string).
  • It's strange, if not wrong, to consider months to be exactly 3030 days.
  • You unnecessarily calculate Math.round(difference_ms/ONE_DAY) twice.
  • yearAge is a bad name for the variable at the beginning, since it doesn't contain anything concerning the year. And you reuse the variable later (then the name fits).
  • var today = new Date(yearNow,monthNow,dayNow); is wrong (and unnecessary), considering you just got monthNow from the current date and added 1. Fortunately you don't actually use it.
  • Testing for the full year to be below 100100 is unnecessary. Only getYear returns such values.
  • It probably would be better just to compare the day, month and year of the birthday and the current day, and do those calculation of the age in days and months only if needed.
  • You should check if formattedDate is actually a Date object before using it (and change the variable name, since it sounds like it contains a formatted string).
  • It's strange, if not wrong, to consider months to be exactly 30 days.
  • You unnecessarily calculate Math.round(difference_ms/ONE_DAY) twice.
  • yearAge is a bad name for the variable at the beginning, since it doesn't contain anything concerning the year. And you reuse the variable later (then the name fits).
  • var today = new Date(yearNow,monthNow,dayNow); is wrong (and unnecessary), considering you just got monthNow from the current date and added 1. Fortunately you don't actually use it.
  • Testing for the full year to be below 100 is unnecessary. Only getYear returns such values.
  • It probably would be better just to compare the day, month and year of the birthday and the current day, and do those calculation of the age in days and months only if needed.
  • You should check if formattedDate is actually a Date object before using it (and change the variable name, since it sounds like it contains a formatted string).
  • It's strange, if not wrong, to consider months to be exactly 30 days.
  • You unnecessarily calculate Math.round(difference_ms/ONE_DAY) twice.
  • yearAge is a bad name for the variable at the beginning, since it doesn't contain anything concerning the year. And you reuse the variable later (then the name fits).
  • var today = new Date(yearNow,monthNow,dayNow); is wrong (and unnecessary), considering you just got monthNow from the current date and added 1. Fortunately you don't actually use it.
  • Testing for the full year to be below 100 is unnecessary. Only getYear returns such values.
  • It probably would be better just to compare the day, month and year of the birthday and the current day, and do those calculation of the age in days and months only if needed.
added 2 characters in body
Source Link
RoToRa
  • 11.4k
  • 1
  • 23
  • 51
  • You should check if formattedDate is actually a Date object before using it (and change the variable name, since it sounds like it contains a formatted string).
  • It's strange, if not wrong, to consider months to be exactly 30 days.
  • You unnecessarily calculate Math.round(difference_ms/ONE_DAY) twice.
  • yearAge is a bad name for the variable at the beginning, since it doesn't contain anything concerning the year. And you reuse the variable later (then the name fits).
  • var today = new Date(yearNow,monthNow,dayNow); is wrong (and unnecessary), considering you just got monthNow from the current date and added 1. Fortunately you don't actually use it.
  • Testing for the full year to be below 100 is unnecessary. Only getYear returns such values.
  • It probably would be much easierbetter just to compare the day, month and year of the birthday and the current day, instead of alland do those calculation of the age in days and months only if needed.
  • You should check if formattedDate is actually a Date object before using it (and change the variable name, since it sounds like it contains a formatted string).
  • It's strange, if not wrong, to consider months to be exactly 30 days.
  • You unnecessarily calculate Math.round(difference_ms/ONE_DAY) twice.
  • yearAge is a bad name for the variable at the beginning, since it doesn't contain anything concerning the year. And you reuse the variable later (then the name fits).
  • var today = new Date(yearNow,monthNow,dayNow); is wrong (and unnecessary), considering you just got monthNow from the current date and added 1. Fortunately you don't actually use it.
  • Testing for the full year to be below 100 is unnecessary. Only getYear returns such values.
  • It probably would be much easier just to compare the day, month and year of the birthday and the current day, instead of all those calculation of the age in days and months.
  • You should check if formattedDate is actually a Date object before using it (and change the variable name, since it sounds like it contains a formatted string).
  • It's strange, if not wrong, to consider months to be exactly 30 days.
  • You unnecessarily calculate Math.round(difference_ms/ONE_DAY) twice.
  • yearAge is a bad name for the variable at the beginning, since it doesn't contain anything concerning the year. And you reuse the variable later (then the name fits).
  • var today = new Date(yearNow,monthNow,dayNow); is wrong (and unnecessary), considering you just got monthNow from the current date and added 1. Fortunately you don't actually use it.
  • Testing for the full year to be below 100 is unnecessary. Only getYear returns such values.
  • It probably would be better just to compare the day, month and year of the birthday and the current day, and do those calculation of the age in days and months only if needed.
added 97 characters in body
Source Link
RoToRa
  • 11.4k
  • 1
  • 23
  • 51
  • You should check if formattedDate is actually a Date object before using it (and change the variable name, since it sounds like it contains a formatted string).
  • It's strange, if not wrong, to consider months to be exactly 30 days.
  • You unnecessarily calculate Math.round(difference_ms/ONE_DAY) twice.
  • yearAge is a bad name for the variable at the beginning, since it doesn't contain anything concerning the year. And you reuse the variable later (then the name fits).
  • var today = new Date(yearNow,monthNow,dayNow); is wrong (and unnecessary), considering you just got monthNow from the current date and added 1. Fortunately you don't actually use it.
  • Testing for the full year to be below 100 is unnecessary. Only getYear returns such values.
  • It probably would be much easier just to compare the day, month and year of the birthday and the current day, instead of all those calculation of the age in days and months.
  • You should check if formattedDate is actually a Date object before using it (and change the variable name, since it sounds like it contains a formatted string).
  • It's strange, if not wrong, to consider months to be exactly 30 days.
  • You unnecessarily calculate Math.round(difference_ms/ONE_DAY) twice.
  • yearAge is a bad name for the variable at the beginning, since it doesn't contain anything concerning the year. And you reuse the variable later (then the name fits).
  • var today = new Date(yearNow,monthNow,dayNow); is wrong (and unnecessary), considering you just got monthNow from the current date and added 1. Fortunately you don't actually use it.
  • It probably would be much easier just to compare the day, month and year of the birthday and the current day, instead of all those calculation of the age in days and months.
  • You should check if formattedDate is actually a Date object before using it (and change the variable name, since it sounds like it contains a formatted string).
  • It's strange, if not wrong, to consider months to be exactly 30 days.
  • You unnecessarily calculate Math.round(difference_ms/ONE_DAY) twice.
  • yearAge is a bad name for the variable at the beginning, since it doesn't contain anything concerning the year. And you reuse the variable later (then the name fits).
  • var today = new Date(yearNow,monthNow,dayNow); is wrong (and unnecessary), considering you just got monthNow from the current date and added 1. Fortunately you don't actually use it.
  • Testing for the full year to be below 100 is unnecessary. Only getYear returns such values.
  • It probably would be much easier just to compare the day, month and year of the birthday and the current day, instead of all those calculation of the age in days and months.
Source Link
RoToRa
  • 11.4k
  • 1
  • 23
  • 51
Loading