title: split string in javascript, reactjs
body: <p>so I'm developing a quiz application sort of, so <a href="https://i.stack.imgur.com/6bVEM.png" rel="nofollow noreferrer">this</a> is my initial state of the app when it first launch, I also have quizApplication.js component store all the question and answers,</p>
  
  <pre><code>{
     question: "I am task oriented in order to achieve certain goals",
     answers: [
        {
          type: "Brown,D,JP",
          content: "Hell Ya!"
        },
        {
          type: " ",
          content: "Nah"
        }
      ]
   },
  </code></pre>
  
  <p>and here is my function to set the user answer </p>
  
  <pre><code>setUserAnswer(answer) {
  if (answer.trim()) {
    const answer_array = answer.split(',');
    const updatedAnswersCount = update(this.state.answersCount, {
      [answer]: {$apply: (currentValue) =&gt; currentValue + 1},
    });
    this.setState({
      answersCount: updatedAnswersCount,
      answer: answer
    }); 
   }
  }
  </code></pre>
  
  <p>I also have a AnswerOption component like so </p>
  
  <pre><code>function AnswerOption(props) {
   return (
     &lt;AnswerOptionLi&gt;
      &lt;Input
       checked={props.answerType === props.answer}
       id={props.answerType}
       value={props.answerType}
       disabled={props.answer}
       onChange={props.onAnswerSelected}
     /&gt;
      &lt;Label className="radioCustomLabel" htmlFor={props.answerType}&gt;
       {props.answerContent}
      &lt;/Label&gt;
     &lt;/AnswerOptionLi&gt;
    );
   }
  </code></pre>
  
  <p>So what im try to do is that whenever the user click on HellYa! it will increment "Brown" and "D" and "JP" by +1, but right now it gives me a new answersCount value as Brown,D,JP: null, so how should I achieve this? Many thanks!</p>