Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to push elements in array based on the avilability

I have an array

let availabilityArray = [currentYearAvailability, previousYearAvailability, previousLastYearAvailability]
console.log(availabilityArray)

when I Console, I can able to find what is available what is not available

const preAuthAvailabilityYears =
    [
      currentYearAvailability ? currentYear : undefined,
      previousYearAvailability ? previousYear : undefined,
      previousLastYearAvailability ? previousLastYear : undefined,
    ]

Console

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I need only the availability years to be displayed in the array instead showing as undefined as third argument, If it is undefined i shouldnot should in array

>Solution :

const preAuthAvailabilityYears =
    [
      currentYearAvailability ? currentYear : undefined,
      previousYearAvailability ? previousYear : undefined,
      previousLastYearAvailability ? previousLastYear : undefined,
    ].filter(Boolean)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading