troubleshooting Question

es6 javascript string interpolation - array within array

Avatar of mikha
mikhaFlag for United States of America asked on
JavaScriptHTMLAJAXJSON
2 Comments1 Solution38 ViewsLast Modified:
I have a json array that i get back from a ajax call. I loop over the data and append it to HTML , this works fine. Now I want to add the list of siblings as a list , which is an array item.family.siblings.

I have used string interpolation below with es6, how can i iterate through the list of siblings below, any suggestions?

     $.each(this.results, (index, item) => {
       let newitem = documment.createElement('div');

       newItem.innerHTML = `<div>
                                                      <span>Name</span><span>${item.name}</span>
                                                       <span>Father</span><span>${item.family.father}</span>
                                                      <span>Mother</span><span>${item.family.mother}</span>
                                                      <ul><span>Siblings</span>
                                                              <li>
                                                      </ul>
                                                       
                                             </div>`  ;

       this.listcontainer.append ( newItem)

     });

{  
  "results" : [
                        { 
                           name : "adam" , 
                           family : {
                                               siblings: [
                                                                    {"relation" : "sister" , "name":"jennifer"},
                                                                    {"relation" : "brother" , "name":"john"}
                                                            ], 
                                               mother : "janet",
                                               father : "thomas"
                                           }
                         }, 
                         { 
                           name : "johnathon" , 
                           family : {
                                               siblings: [
                                                                    {"relation" : "brother" , "name":"scott"},
                                                                    {"relation" : "brother" , "name":"chuck"}
                                                            ], 
                                               mother : "debby",
                                               father : "shawn"
                                           }
                         },
                         ....

                       
                     
  ]
}
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros