Reversing an integer using for...of

Hi,

I am trying to reverse an integer, works perfectly using reverse inbuilt method but when i use the for…in , my test cases fail.

I do not understand why when i use the for…in method , my test cases fail. Any advise will be appreciated.

// --- Directions
// Given an integer, return an integer that is the reverse
// ordering of numbers.
// --- Examples
//   reverseInt(15) === 51
//   reverseInt(981) === 189
//   reverseInt(500) === 5
//   reverseInt(-15) === -51
//   reverseInt(-90) === -9

function reverseInt(n) {
    let x = n.toString().split('');

    for(let i of n) {
        x.push(n[i])
    }
    return parseInt(x.join("")) * Math.sign(n);

    // let reversed = n.toString().split('').reverse().join('');
    // if(n < 0) {
    //     return parseInt(reversed) * -1;
    // }
    // return parseInt(reversed);
}

module.exports = reverseInt;

Try to log what your function returns when you use for…in

function reverseInt(n) {
    let x = n.toString();
    let y = '';

    for(let i of x) {
        y = i + y
    }
    return parseInt(y) * Math.sign(n);
}