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
  • 30,747
  • 12
  • 76
  • 133
max
  • 81
  • 1
  • 5

1 Answers1

2

You need to return something like return year - myyear;

Joseph Evans
  • 1,350
  • 10
  • 14