Makers of Kerala

@makersofkerala

Javascriptilengane praayam ganikkaam

Ezhuthu thiyathi

Ee Javascriptil vayassu kandethunnathu enganeyaanennu kaanano ningalkku?
Sankaradi from Vietnam Colony
Kaanam
Mohanlal from Vietnam Colony

// Janma thiyathi aayirikkanam input
const calcAge = (dateString) => {

  // Ithu innathe thiyathiyude millisecond tharum
  const birthday = new Date(dateString).getTime();

  // Oru varshathile millisecondugal
  const msInYear = 365.25*24*60*60*1000;

  // Ithanu vayassu ganikkunna function
  return parseInt((Date.now() - birthday) / msInYear);

}
	      
	    
Aadyam ingane function declare cheyyanam.
Sankaradi from Vietnam Colony
Ennitingane vilikanam calcAge(“12 Jan 1999”) appo 21 ennu kittum!
Sankaradi from Vietnam Colony

2 Reactions

Innocent from Vietnam Colony
Mohanlal from Vietnam Colony

Pinne oru kaaryam. Aa dateString ee roopathilokke adikkanam:

  • 2020 02 01 (yyyy mm dd)
  • 01 Feb 2020 (dd mmm yyyy)
  • 1264962600000 (milliseconds since 1970)

Sankaradi from Vietnam Colony

Muzhuvan rekha kaanano? Ithaana rekha: ECMA 262 Specification

Sankaradi from Vietnam Colony
Ayyeee . . .
Innocent from Vietnam Colony

Poornaroopam

const calcAge = (dateString) => {

  const birthday = new Date(dateString).getTime();

  const msInYear = 365.25*24*60*60*1000;

  return parseInt((Date.now() - birthday) / msInYear);

}

// calcAge("12 Jan, 1999") => 21
	  
	

Ee postinte designilekku vilapetta nirdeshangal thanna Athul Cyriacinum Gopikrishnanum Jithin Shaykkum nandi!

Ini varaan pokunna postugal udanadi labhikaanayi Makers Broadcastvarikkaaravuga

Ee post ithuvare 1 thavana vitharanam cheythu.