-
I would recommend Air Train -> LIRR (Jamaica) -> NJT (Penn Station) -> Air Train (Newark Airport).
If it’s late at night, I would research if there are direct busses which might be cheaper with fewer transfers and less hassle.
The above would cost around $35 but I would highly discourage trying to go cheaper by using the bus or subway.
It will take longer than you ever imagined, or than Google Maps tells you.
The LIRR portion is a little cheaper when you select “city ticket” (which used to be only available on weekends, but seems to be available throughout the week now).