0

I got a response from the backend the response is an object how can I get the arrays from the object I tried to use Object entries but I can't get the arrays can you please help meenter image description here

2 Answers 2

1

You are looking for the Object.values to retrieve just the value part of your object.

Example:

const object = {
  "20-01-22": ['a', 'b', 'c'],
  "21-01-22": ['b', 'c'],
  "22-01-22": ['d', 'f']
};

const arrays = Object.values(object)

// => [['a', 'b', 'c'], ['b', 'c'], ['d', 'f']];
Sign up to request clarification or add additional context in comments.

Comments

1

You can use a for:

Example:

const cars = ["BMW", "Volvo", "Saab", "Ford", "Fiat", "Audi"];

let text = "";
for (let i = 0; i < cars.length; i++) {
  text += cars[i] + "<br>";
}

document.getElementById("demo").innerHTML = text;

Source: https://www.w3schools.com/js/tryit.asp?filename=tryjs_loop_for

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.