Project Euler Problems 1 to 100 - Problem 38: Pandigital multiples

Tell us what’s happening:

pandigitalMultiples(8) should return 78156234,
pandigitalMultiples(9) should return 932718654.
Project Euler is a difficult mathematical theory which is no easy path to achieve success. Your help will surely be appreciated to accomplish this wonderful mathematical endeavor.

Your code so far

function isPandigital(num) {
    const str = num.toString();
    if (str.length !== 9) return false;
    const digits = new Set(str);
    return digits.size === 9 && !digits.has('0');
}

function concatenatedProduct(num, n) {
    let result = '';
    for (let i = 1; i <= n; i++) {
        result += (num * i).toString();
    }
    return parseInt(result, 10);
}

function pandigitalMultiples(limit) {
    let maxPandigital = 0;
    for (let num = 1; num < 10000; num++) {
        let concatenated = '';
        for (let n = 1; concatenated.length < 9; n++) {
            concatenated = concatenatedProduct(num, n);
            if (concatenated > maxPandigital && isPandigital(concatenated)) {
                maxPandigital = concatenated;
            }
        }
    }
    return maxPandigital;
}

console.log(pandigitalMultiples(78156234)); // Should return 78156234
console.log(pandigitalMultiples(932718654)); // Should return 932718654


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0

Challenge Information:

Project Euler Problems 1 to 100 - Problem 38: Pandigital multiples

Can you talk to us in your own words about what you have tried and how you are stuck?