There seems to be a problem with this code as in it doesn't check for the largest palindrome. I mixed it with the example they showed of largest palindrome from two digit numbers (The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99) and it worked. I've looked around, but I still don't understand exactly why my code doesn't show the final product. If someone is willing to explain instead of just giving the answer, that would be quite helpful
for(var i = 100; i < 1000; i++) {
for(var j = 100; j < 1000; j++) {
var total = String(i*j);
var regularI = total.substring(0, Math.floor(total.length/2));
var regularJ = total.substring(total.length/2,total.length);
var reversedJ = regularJ.split("").reverse().join("");
if(regularI === reversedJ) {
console.log("SUCCESS\nTotal: " + (i*j) + "\nI: " + i + "\nJ: " + j);
}
}
}