Project Euler Problems 1 to 100 - Problem 4: Largest palindrome product

Tell us what’s happening:
I wrote this code on website and it shows infinite looping but I wrote the code on vs code it ran can someone tell me why

Your code so far

function largestPalindromeProduct(n) {
let n1=1,n2=1;let product=1;let i;
   for ( i = 1; i < n; i++) 
        {n1 = n1 * 10 ;}
    for ( i = 1; i <=n; i++) 
        {n2 = n2 * 10 ;}
      for ( i = n1; i < n2; i++) 
      {
        for (let j = n1; j < n2; j++) 
        {
            let prod = i * j;
            let prod1=prod;
            let sum=0;
            while(prod1>0)
            {
              sum=(sum*10)+(prod1%10);
              prod1=prod1/10;
            }
            if(sum==prod && prod>product)
            product=prod;
        }
      }
      return product;
}
largestPalindromeProduct(3);

Your browser information:

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

Challenge: Project Euler Problems 1 to 100 - Problem 4: Largest palindrome product

Link to the challenge:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.