i have array with objects like this:
{
tab: "Quality Assurance",
value: "qa",
titles: [
"Web App Interfaces3",
"Backend Application Development",
"Single-page Apps",
"Technical Backend Audit",
],
content: [
"3We build web apps and websites with clean architecture and user-friendly interfaces.",
"We build web apps and websites with clean architecture and user-friendly interfaces.",
"We build web apps and websites with clean architecture and user-friendly interfaces.",
"We build web apps and websites with clean architecture and user-friendly interfaces.",
],
}
and i want to iterate through this array and get next output:
"Web App Interfaces3"
"3We build web apps and websites with clean architecture and user-friendly interfaces."
"Backend Application Development",
"We build web apps and websites with clean architecture and user-friendly interfaces."
i.e first element from titles and first element from content and so on
i tried this but it’s not what i need
{data.map((tab, index) => (
{tab.titles.map((title) => {
return <h4 key={index}>{title}</h4>;
})}
{tab.content.map((text) => {
return <p key={index}>{text}</p>;
})}
))}
2
Answers
Try this
In a pure JavaScript way, you can simply achieve this via
Array.forEach()
method. I am assuming bothtitles
andcontent
array have same length.Live Demo :