MCPcopy Create free account
hub / github.com/AyushSaini00/60minuteJavaScript / calcAge

Function calcAge

Age-Calculator/app.js:24–36  ·  view source on GitHub ↗
(age)

Source from the content-addressed store, hash-verified

22}
23
24function calcAge(age){
25 let year = Math.floor(age); //21
26 let remainingYear = age - year; //0.375
27
28 let monthDiff = remainingYear * 12; //4.5
29 let month = Math.floor(monthDiff); //4
30
31 let remainingMonth = monthDiff - month; //0.5
32 let day = Math.floor(remainingMonth * 30); //15
33
34 //display age to UI
35 displayAge(year, month, day);
36}
37
38function displayAge(y,m,d){
39

Callers 1

getAgeFunction · 0.85

Calls 1

displayAgeFunction · 0.85

Tested by

no test coverage detected