Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Convert and modify Array in Object toa string

Avatar of lvmllc
lvmllcFlag for United States of America asked on
JavaScript
3 Comments1 Solution218 ViewsLast Modified:
Te project I am working with provides me in the prebuilt drupal page with an object containing an array of FIPS codes that I am to use. To demonstrate what is being provided

var drupal={settings:{
     geo_settings:{
          primary_state_fips: "19",
          primary_county_fips: "19001", 
          compare_to: "custom", 
          custom_list: ["19003", "19005", "19007"], 
          geo: "County"}, 
     vars:{myColor: "Yellow", otherStuff: "blah blah" }
     }
}


I need to extract the custom_list array values and do two things with the data.  First I need to trim off the first to characters of each so in the example I am removing the 19.

Next I need to convert this data into a single string var.

So essentially want I want in this example is

theList = "003, 005, 007";

I should note that the length of the custom list value set varies from 1 - 15.

Any advice on how to make this elegant is appreciated - I can write code to accomplish is but it is not pretty so looking for simple efficient solution.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Luis Pérez
Luis PérezFlag of Spain imageSoftware Architect in .Net

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answers