Code Snippet:
function Button(props) {
var ans = [
["56","30","11","20"],["1","-2","2","-1"],
["odd","even","none","both"]
];
var button = [], i;
for(i = 0; i <= 3; i++) {
button.push(<button key={i} onClick={()=>props.ind(i)}>
{ans[props.q-1][i]}
</button>)
}
return (<div>{button}</div>)
}
I am a newbie at using fatarrows and react.I am making a quizzing interface.Here each of the four buttons (i=0 to 3) holds a choice for a specific question no.(q) On checking web devs i found that for each of the 4 buttons,value of i passed in props.ind method is 4,i.e value of i after final increment.