Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Array Iteration Methods Array Manipulation Practice map()

3 Answers

Travis Alstrand
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Travis Alstrand
Treehouse Project Reviewer

Hey Joseph Quintiliano

This is happening because when using substring, the second number we provide is excluded. So using (0, 2) would only return index 0 & 1. Using (0, 3) would return index 0, 1 & 2.

You can read more on it here

Also, check your order of your => you'll want it to be >=.

Steven Parker
Steven Parker
231,248 Points

According to the MDN page for substring(), it returns the part of the string from the start index up to and excluding the end index. Another way to think about is arg2 - arg1 = how many.

So, with the values of 0 and 3, you get the characters at indexes 0, 1, and 2, but not 3. That's 3 letters.

With the values of 0 and 2, you only get back 0 and 1 (just 2 letters).


Update: I think Travis might have misunderstood part of the instructions. Your use of => is correct for creating an arrow function to pass to the map() method. The >= operator would be for a comparison expression.