Instead of this complex condition, you could use the `nextSibling` property to know whether the input field is the last child of its parent. So the condition would become:
```js
if (inputField.nextSibling != null && inputField.value === "") {
```