Age Calculator Brick Workaround

Abby Updated by Abby

We currently have an age calculator brick, however, it's made for V2, if you're using V3 you can make it work with the following workaround:

Import the brick

Open brick and go to the Javascript block

Remove the current code and add the following

let landbotScope = this;

function getAge(datepicker)
{var today = new Date();ย var birthDate = new Date(datepicker); var age = today.getFullYear() - birthDate.getFullYear();var m = today.getMonth() -birthDate.getMonth();ย if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {ย age--;}ย ย 

landbotScope.setCustomData({age: age})}getAge("@{datepicker}");

That's it!

How did we do?

Contact