From 0e1d5f0bf8916f1e127798c635a6ce9b3336e60a Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Mon, 11 Mar 2024 10:49:02 +0700 Subject: [PATCH] refactor(utils): merge 2 statement of same conditions --- src/interfaces/utils.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/interfaces/utils.ts b/src/interfaces/utils.ts index ef23c9b1..d9edd9d9 100644 --- a/src/interfaces/utils.ts +++ b/src/interfaces/utils.ts @@ -5,8 +5,10 @@ export function calculateAge(start: Date, end = new Date()) { let month = end.getMonth() - start.getMonth(); let day = end.getDate() - start.getDate(); - if (month < 0) year -= 1; - if (month < 0) month += 12; + if (month < 0) { + month += 12; + year -= 1; + } if (day < 0) { month -= 1; day =