0

I'm trying to make a function that calculates age by someone inputting their birth date information. The function does not seem to work when activating the function.

function calculate() {    
    var mymonth = 12    //inputs
    var myday =  01     
    var myyear = 1967    
    var month = new Date().getMonth(); // current dates
    var day = new Date().getDate();
    var year = new Date().getFullYear();

    if (month > mymonth) {
            year - myyear;
            return;

    } else if (month > mymonth) {
            year - myyear;
            return;

    } else if (month == mymonth && day == myday){
            year - myyear;
            return;
    } else { 
            year - myyear - 1;
            return;    
    }
}    
calculate();
StepUp
  • 36,391
  • 15
  • 88
  • 148
max
  • 161
  • 1
  • 1
  • 6

1 Answers1

2

You need to return something like return year - myyear;

Joseph Evans
  • 1,360
  • 9
  • 14