I am new to Reactjs and got stuck while experimenting in my code.I am using math.random to find values between 0-9 and concatenating with valvar to get multiple variables.I want to find the state of corresponding variable.
Here is my code.
getInitialState: function(){
return{valvar2:"",valvar3:"",valvar4:"",valvar5:"",valvar6:"",valvar7:"",valvar8:"",valvar9:""}
},
handleClick: function(){
var createVar="";
createVar ="valvar"+Math.floor((Math.random() * 9) + 1);
if(this.state.createVar==""){
this.setState({createVar:"HELLO"})
}
But this code is not working, I am not sure why.This is just an example not my original code.