Check out example codes for "using html forms to define javascript variables". It will help you in understanding the concepts better.

Code Example 1

var firstName = document.getElementsByName("firstname")[0].value;

Learn ReactJs, React Native from akashmittal.com