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


Related Query

More Query from same tag