loading
open in
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function largestPalindromeProduct(digit) {
  // Good luck!
  if(digit === 2) {
    for(let i=99; i>9; i--) {
      for(let j=99; j>9; j--) {
        let number = i * j;
        let str = number.toString();
        if(str === str.split("").reverse().join("")) {
          console.log("here i = "+i + " j = "+ j);
          return number;
        }
      }
    }
  }

    for(let i=999; i>99; i--) {
      for(let j=999; j>99; j--) {
        let number = i * j;
        let str = number.toString();
        if(str === str.split("").reverse().join("")) {
          console.log(i + " , " + j);
          return number;
        }
      }
    }

  return undefined;
}

largestPalindromeProduct(3);
Native Browser JavaScript