tallgirltaadaa
tallgirltaadaa

Reputation: 1834

Cant get this simple function to return anything

Im just trying to formate this list, currently the function accepts skills which is a comma separated list

skills = Mobile, iOS (Swift,Objective C), Android (Java), JavaScript, React, Data processing, GIS, Cartography, Web, Design/UI/UX

skills_array = ["Mobile", " iOS (Swift", "Objective C)", " Android (Java)", " JavaScript", " React", " Data processing", " GIS", " Cartography", " Web", " Design/UI/UX"]

Im not sure why this function does not return anything

formatSkills(skills) {

     let skills_array = skills.split(',')
     skills_array.map(skill => {
     return <li>skill</li>
     })
  }

seems pretty simple so not sure what i could be missing

Upvotes: 0

Views: 60

Answers (1)

intentionally-left-nil
intentionally-left-nil

Reputation: 8274

You have two functions. Your map function is returning a <li>..</li>, and your formatSkills function is not returning anything right now. Add return to the result of your map call to return that from the function.

formatSkills(skills) {
   let skills_array = skills.split(',')
   return skills_array.map(skill => {
     return <li>skill</li>
   });
}

Upvotes: 4

Related Questions