Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:

This question already has an answer here:

I have the following string:

var group = "one+two+three";

Each value in the string is separated by a +, and I wanted to add them separately in an array, so It could then become:

var group_array = ["one", "two", "three"];

How can I do this?

share|improve this question

marked as duplicate by Felix Kling javascript Jun 5 at 17:16

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
While you received several answers already, this is really a thing you should have been able to find with a simple web search, as explained in "how to ask questions on Stackoverflow" – Mike 'Pomax' Kamermans Jun 5 at 17:16
    
You really couldn't search for [javascript] string to array? – Felix Kling Jun 5 at 17:17

2 Answers 2

Use split() like

var group = "one+two+three";
var groupArray = group.split('+');
console.log(groupArray);

share|improve this answer

You can simply split() it:

var groupArray = "one+two+three".split("+");
// -> will give you ["one", "two", "three"];

Try

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.