title: How to convert string to integer from json response in reactjs
body: <p><a href="https://i.stack.imgur.com/LPSd4.png" rel="nofollow noreferrer">How to convert string to int from json</a></p>
  
  <pre><code>     if(this.state.chartCategory == 'D3Chart'){
        console.log("chartdata for d3 charts", this.state.d3line.chartData);
        var a = parseInt(this.state.d3line.chartData)
        console.log("a", a);
          switch(this.state.chartType){
            case 'area': return &lt;div  style={{width: 900, height:300}}&gt;&lt;Areagraph  data = {this.state.d3line.chartData} vars = {{x: this.state.d3line.x, y: this.state.d3line.y}} dispatch = {this.showFilter} title = {this.state.data.chartName}/&gt;&lt;/div&gt;;
            case 'pie': return  &lt;div style={{width: 900, height:500}}&gt;&lt;Piegraph  data = {this.state.d3line.chartData} vars = {{x: this.state.d3line.x, y: this.state.d3line.y}} dispatch = {this.showFilter} title = {this.state.data.chartName}/&gt;&lt;/div&gt;;
            case 'bar': return  &lt;div  style={{width: 900, height:300}}&gt;&lt;Bargraph  data = {this.state.d3line.chartData} vars = {{x: this.state.d3line.x, y: this.state.d3line.y}} dispatch = {this.showFilter} title = {this.state.data.chartName}/&gt;&lt;/div&gt;;
            case 'line' : return &lt;div  style={{width: 900, height:300}}&gt;&lt;Linegraph  data = {this.state.d3line.chartData} vars = {{x:this.state.d3line.x, y: this.state.d3line.y, group: this.state.d3line.x}} dispatch = {this.showFilter} title = {this.state.data.chartName}/&gt;&lt;/div&gt;;
            default: return null;
         }   
  
      }
  </code></pre>
  
  <p>I am getting a as NAN i want to check if the value is integer convert string to integer else it should remains same </p>
  
  <p>Thanks in advance</p>