SyntaxFix
Write A Post
Hire A Developer
Questions
The proper test is:
if (capital != null && capital.length < 1) {
This ensures that capital is always non null, when you perform the length check.
capital
Also, as the comments suggest, capital is null because you never initialize it.
null