I have a comma separated list of values, and I need to remove the one that is equal to a certain value.
myList = '10,20,30';
myList.remove(20); // === '10,30'
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here is some tested and jslinted code that does what you’re asking for.
However, I question why you would do this. Arrays should be stored in array objects, not in string literals. If you need to display the list, then convert to a delimited list at display time. If your input is a string, then split it at input time and keep it internally as an array. I really strongly believe this is the best practice for you and in the long run you will have much easier to maintain code that is much easier to understand.