functionlargestPalindromeProduct(n){// Good luck!constisPalindrom=n=>{returnString(n).split("").reverse().join("")===String(n);}letlargestPalindrome=0;constlowerBound=Number(`1${Array.from({length:n}).join(0)}`);constupperBound=Number(`${Array.from({length:n+1}).join(9)}`);console.log({upperBound,lowerBound})for(vari=lowerBound;i<=upperBound;i++){for(varj=lowerBound;j<=upperBound;j++){constproduct=i*j;if(isPalindrom(product)&&product>largestPalindrome){console.log(i,j,product,largestPalindrome)largestPalindrome=i*j;}}}returnlargestPalindrome;}largestPalindromeProduct(2);
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Here is freeCodeCamp version of it