This reminds me of that video where LGR reviewed a keyboard with a PIZZA keyboard key. Probably more useful of a usecase than this really... (https://youtu.be/USQxZc9nmtE)
Using JS over CSS for sizing elements rarely is a 'better solution', mostly because of flashes of unstyled content - especially on mobile where it might take longer for the JS to fully initialise.
Like other comments on here say, just use height: 100% instead.