How to get arrays inside an array Javascript Hello i have this code in javascript where an array has inside arrays with tags, the arrays are dynamic so i need a loop to fetch the tags with its values, this is my code i have done:
let allCurrencyDatasets = [];
allCurrencyDatasets.push(
allCurrencyName.map(currency => ({
label: currency,
borderColor: generateRandomColor(),
data: allCurrencyValues
}))
)
data = {
labels: created_date,
datasets: allCurrencyDatasets
};
The allCurrencyDatasets has many arrays inside
You can use a for loop to iterate through the allCurrencyDatasets array and access the inner arrays.
for (let i = 0; i < allCurrencyDatasets.length; i++) {
let innerArray = allCurrencyDatasets[i];
// do something with the inner array
}
You can also use the forEach method to iterate through the allCurrencyDatasets array and access the inner arrays.
allCurrencyDatasets.forEach(innerArray => {
// do something with the inner array
});
Please sign in or create an account to participate in this conversation.