# How to convert bigNumber array to int array?

I have a smart contract method that return an array of uint256,

but when I `console.log` the result I got this :

``````[ BigNumber { s: 1, e: 1, c: [Array] } ]
``````

How can we convert it to array of numbers? `toNumber()` work for a single object

Consider a deployed contract defined as follows:

``````pragma solidity ^0.4.25;
contract MyContract {
uint256[] public data;
function write(uint256 entry) public {
data.push(entry);
}
function read() public constant returns(uint256[]) {
return(data);
}
}``````

After having called `write(1)`, `write(3)` and `write(9)`, the expected outputs are as follows, depending on which web3 version is in use:

``````MyContract.methods.read().call(function(error, result){
if(!error) {
console.log(result);
}
});``````

### Outputs:

``````[ '1', '3', '9' ]
``````

``````MyContract.read(function(error, result){
if(!error) {
console.log(result);
}
});``````

### Outputs:

``````[ BigNumber { s: 1, e: 0, c: [ 1 ] },
BigNumber { s: 1, e: 0, c: [ 3 ] },
BigNumber { s: 1, e: 0, c: [ 9 ] } ]
``````

As mentioned by user mirg, the results from the `web3@0.20` call must be individually converted into a number or string.

### Conversion example:

``````var array = [];
for(var i=0;i<result.length;i++){
array.push(result[i].toString());
}
console.log(array);
``````

### Outputs:

``[ '1', '3', '9' ]``

## Appendix

### array100.js (web3@1.0.0-beta.36)

``````const Web3 = require("web3");
const provider = web3.currentProvider;
var MyContract = new web3.eth.Contract(contractAbi, contractAddress);
if(!error) {
console.log(result);
}
});
``````

### array020.js (web3@0.20)

``````const Web3 = require("web3");
const web3 = new Web3(new Web3.providers.HttpProvider(address));
if(!error) {
var array = [];
for(var i=0;i<result.length;i++){
array.push(result[i].toString());
}
console.log(array);
}
});
``````

Hope that helps.

Stay super!

/Javi