Reputation: 281
With Google Apps Script, I like to add a 2D array to the end of an existing 2D array. But the following codes returned a 3D array with another nest inside, like “ [['AAPL', 'Strong'], ['MSFT', 'Strong'], [[ 'TSLA', 'Weak'], ['VZ', 'Neutral']]]”. I want the 2D output, like [['AAPL', 'Strong'], ['MSFT', 'Strong'], ['TSLA', 'Weak'], ['VZ', 'Neutral']]. What should be changed in the codes! Thank you for any guidance!
function test() {
var data1 = [['AAPL', 'Strong'], ['MSFT', 'Strong']];
var data2 = [['TSLA', 'Weak'], ['VZ', 'Neutral']];
var output = data1;
output.push(data2);
console.log(output);
}
Upvotes: 1
Views: 1412