Why can't I make a function that logs my data?
If I don't do console.log in the function, I'm getting the values, but when doing it in a function, the data is hidden.
let stoneArray = [];
let beginningStone = {
a: 200,
b: 200,
c: 10,
d: 2,
e: 5
};
stoneArray[0] = beginningStone;
function consoleData() {
console.log('stoneArray = ' + stoneArray);
}
consoleData();
console.log(stoneArray);
console.log('stoneArray = ' + stoneArray);In the statement, you are appending to string, and so the object is appended as[object object]. Try logging without string. e.g -console.log(stoneArray);console.log('stoneArray = ', stoneArray);