About ProjectEuler problem 4 and code structure

I’m doing this challenge:

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.

Find the largest palindrome made from the product of two n-digit numbers.

So i need to implement

function largestPalindromeProduct(n) { }

As I see it, there will be check ‘is number palindromic or not’ somewhere inside function.
So I already have pre-written function palindrome(n), because I have done challenge from JS course - Palindrome checker.

So my question is: what is the best practise in terms of code structure:

optionA : define palindrome() first, then define largestPalindromeProduct() and just call palindrome() when it is needed.

optionB: define largestPalindromeProduct() with nested palindrome().

I’m interested not only in this particular case, but also in logic of making such decisions in general.

SideNote: I have some rudimentary experience with Python, and I was always ended up with optionA, because it was shown to me as example, but I never gave it much thought back then.

I tend to use option A - it makes your logic more modular and other future functions could use those modules of logic independently. That said, there are no absolute rules in JS for this.

Yeah, now when i think about it, it seems like optionA is more scalable/maintainable one.