javascript - Convert array of objects into an array but in a different format. -


i have array of objects shown below. did console.log(values); , got below result

["15- s&p", "us- ex us", "al- ex cl"]  0:"15- s&p" 1:"us- ex us" 2:"al- ex cl" length:3 __proto__:array(0) 

i want output in array values follows.

[s&p, ex us, ex cl] 

all values before '-' eliminated , values after '-' taken , put in array. e.g. '15- s&p' changed 's&p'. can please let me know how achieve this.

you use array#map , string#split return text after - sign every element.

var arr = ["15- s&p", "us- ex us", "al- ex cl"],      res = arr.map(v => v.split("- ")[1]);            console.log(res);


Comments