Hi,
First of all, you need to know the difference between null and undefined in JavaScript. You can google the keyword "javascript null undefined". In your case, input1 is undefined. That's why the second if control is executed.
If you want to do something when input1 is not defined by the frontend user, you can use the following two logics.
if (input1 === undefined) {
...
}
OR
if (!input1) {
//null or undefined
...
}
as the usual way.
Best regards,
Wenjun