Echo JS 0.11.0

<~>
jklu 106 days ago. link 1 point
Ok, you're trolling right ? ;-)

First of all, you don't need to create the arrays
(neither in python nor in javascript)

Secondly a string reverse in javascript can be as easy as 
string.split("").reverse().join("")
(which is a bit more readable than the Python shorthand version ;-))

Lastly why would you convert to strings ?

//
var y = 0;
for (let i = 100; i <= 999; i++) {
  for (let k = 100; k <= 999; k++) {
    let x = k * i;
    let result = 0;
    let candidate = x;
    while (candidate > 0) {
      let remainder = x % 10;
      candidate = Math.floor(candidate / 10);
      result = result * 10 + remainder;
    }
    if (x == result && x > y) {
      y = x;
    }
  }
}
console.log(y);
//

Replies