3. Finding the Answer [How To Make JS Your Own]


#1

Hi. I'm having trouble finding what is wrong with the code. It lets me continue to next exercise but I get an error: TypeError: pairs.push is not a function in output screen. Please see the link to the exercise:

https://www.codecademy.com/courses/javascript-intermediate-en-2nQQb/0/3#

JS code

`

var pairs = [];

for(var x = 10; x < 100; x = x + 1) {
 for(y = 10; y < 100; y += 1) {
  pairs = (x*x).toString() + (y*y);
   
    if(pairs == 98019801){
    
   pairs.push(x + "," + y);
   
    };
};
};

`


#2

You changed pairs from being an array, (which has the .push method) to a string, which doesn't. :slight_smile:


#3

This is what I did now. It gives no error but also no output on the screen.

`

var pairs = [];

for(var x = 10; x < 100; x = x + 1) {
for(y = 10; y < 100; y += 1) {
  pairs = (x*x).toString() + (y*y);
   
    if(pairs == (x*x) + (y*y)){
    
   pairs.push(x + "," + y);
   
    };
};
};`

If I put this piece in I can continue:

pairs = (x*x).toString() + (y*y);

But how should I change it to give output if you say I made it a string??
I have to use pairs.push(...) because they say so.

Sorry I just can't understand, not even with the Hint they give.