Javascriptilengane praayam ganikkaam
Ee Javascriptil vayassu kandethunnathu
enganeyaanennu kaanano ningalkku?
Kaanam
// 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.
Ennitingane vilikanam
calcAge(“12 Jan 1999”)
appo 21 ennu kittum!2 Reactions
Pinne oru kaaryam. Aa dateString
ee roopathilokke adikkanam:
2020 02 01 (yyyy mm dd)
01 Feb 2020 (dd mmm yyyy)
1264962600000 (milliseconds since 1970)
Muzhuvan rekha kaanano? Ithaana rekha: ECMA 262 Specification
Ayyeee . . .
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.