`isNaN` is not what you want here. For example `isNaN('')` is false :-)

I think you can try `!isFinite(lastPart)`.