ageFromDob afterQuery causing data load failure?

Hi All, not sure if this will be happening to others? But every time I use the code from Wix code for calculating fields in dataset it causes a data load failure? Any reason or answers? @sapirh @alexander-wix @yisrael-wix

We need to see your code and the error! Or you were expecting us to take guess?

This is the code: my data collection is called “Details” the Item fields of Name and surname are correct.

export function Details_afterQuery(item, context) {
item.fullName = item.firstName + " " + item.surname;
item.age = ageFromDob(item.dob);

return item;
}
function ageFromDob(dob) {
const now = new Date();
const days = now.getDate() - dob.getDate();
const months = now.getMonth() - dob.getMonth();
let age = now.getFullYear() - dob.getFullYear();

if (months < 0 || (months === 0 && days < 0)) {
age–;
}

return age.toString();
}

it seems to be a difficulty with this function as when it is removed from the data.js backend file everything else works. whilst this code is within the data.js file it works intermittently but often throughs the data collection into a data load failure.

internet connection is fine without any issues so again must only be to do with the code.

any help and guidance would be greatly appreciated.

Si