JS truthy surprise and off by one at end