I should get printed on the page "Hello name" if age is eighteen or more. Otherwise, the page prints "You are too young". Now the page prints only "You are too young".
function HelloName() {
const [name, setName] = React.useState({name: ''});
const [age, setAge] = React.useState({age: ''});
const inputChanged = (event) => {
setName({...name, [event.target.name]:
event.target.value})
}
const formSubmitted = (event) => {
event.preventDefault();
if (age >= 18) {
alert("Hello " + name); }
else {
alert("You are too young"); }
}