score:1
Accepted answer
please update this code:
{persons.map((item, index) => {
return (
if (index === 0) {
<p>
{item.address}
</p>
<p>
{item.company}
</p>
<p>
{item.name}: {item.telephonenr}
</p>
} else {
<p>
{item.name}: {item.telephonenr}
</p>
}
)})}
your output will be look like this:
wallstreet
abc
john:12345
rick:12857
eva: 38665
score:1
you can use map object map object
const map = new map()
map.set([address, company].tostring(), [{name, telephonenr}])
then you need to get the value and set it with the new item and if the key is the same it will map to the same key-value pair and after that, you can iterate the map object and to print it
Source: stackoverflow.com
Related Query
- How can I skip value in array using map or group elements in Array?
- How can use my object like a array using with map function
- ReactJS: How can I create multi-level array using Map
- How can I fetch data from an array of objects, pass it through an API end point to .fetch() the needed object value using React?
- How can I set a specific position to array elements with the map function and a given index?
- How can I map an array to heatmap in react using react-heatmap-grid?
- How can I use Map function for an Array with values and another array as a value in Javascript
- How can I use multiple refs for an array of elements with hooks?
- how to group array of objects by value in reactjs / javascript
- How can I dynamically generate DOM elements using ReactJS?
- How I can update array field value in redux-form?
- How to add value to Map initialized in state using react?
- How can I export the type of an Action creators return value using Flow?
- How to add className to list from map array depending on object value
- How to update specific value in a array of JSON values in React, can anyone please explain this
- How to dynamically create button for calling specific action using map array in react
- How can i get the location of the user - Using at React Map GL
- How to change/add value of a certain row of an array using useState Hook in React
- How can I group objects alphabetacally within an array by a specific key?
- How can I sort an array using immer?
- How can I map a concatenated value for this state, without it being passed as a string?
- How can I map a nested array from JSON?
- How can I show certain elements from an array based on a React State?
- How to reduce and get value from object array using javascript
- How can I send a file within an array of objects using formData.append()
- How to skip certain elements when using javascript map()
- How to map local array in React card component using Typescript?
- How to remove elements from array using redux, immer, react
- How can I set state on individual elements in a mapped function using React?
- How to add items into specific Id using the react array map method
More Query from same tag
- Do I need to install @types/react to work with React in a TypeScript project?
- How to make a phone call in reactjs
- Prevent pressing escape button
- React Javascript displaying/decoding unicode characters in a <title> element
- Should I handle errors in my action creators
- React get and show attached files in Rails
- How to format dates on frontend
- How can I make this function shorter with ES6?
- trying to fetch id from a api from another api in react hooks
- How to change Bootstrap navbar color on scroll in React.js?
- New to jest - how would I write a test for this method?
- Loop into array object then check if there's a equal value?
- Reactjs TextField helperText
- How to use context in different component
- Unpacking an array and returning its elements
- Embeed script tag in React.js render
- Which is the best way to store a list of data in localStorage and display them when searched using a React app
- Is it possible to access the applied filters at List Component rendering time
- It is better bind methods in the constructor of a component or in the render method?
- onBlur resets value in react-select
- Reactjs: Inject a text into React-Select Input field
- useState without events
- add popover when event is clicked in react-big-calendar?
- ReactJS href attribute of collapse can't take props value
- how can I customize mui pagination bar?
- Why do I have to invoke promise.then() myself to test ES6 promises?
- align divs to the right side of the window in react
- MongoDB filtering and sorting an array
- React with Brackets
- Getting TypeError: _this2.props.handleClick is not a function when passing redux prop from container to presentational component in react