Given an integer, for example 20, I am trying to calculate how many months and years are represented by that number. For 20, the result would be 1 year and 8 months. How can this be achieved using JavaScript?
switch (props.term) {
case (props.term === 12):
setYears(1)
break;
case (props.term > 12):
...
break;
default:
break;
}
Are there any alternative methods to achieve this calculation?