Question:
What values can you store in state?
Answer
A React component’s state is a plain JavaScript object, so it can store any valid value that is storable within a JavaScript object. This includes booleans, strings, numbers, and even other objects which you can nest within the state.
// making all uppercase
city.toUpperCase();
//removing spaces and making all lowercase
city = city.trim().toLowerCase();
//capitalizing the first letter
cityCapitalized = city.charAt(0).toUpperCase() + city.slice(1);
Comments