Suhan Gui Suhan Gui - 20 days ago 5
Javascript Question

Assigning numbers to a variable

I have 2 variables equal to 2 separate numbers. I want to assign those two numbers into the third variable.

The code should look something like this:

var x=1;
var y=2;
var cell=[];

return cell[x][y];
//I want the code to return cell[1][2]

Answer

If you want an array containing the two variables try

var cell = [x, y];
return cell;
Comments