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
MUZ140191 Prudence Goreraza
9,480 PointsCreate an array named data and store any 3 numbers in it.
my code keeps on saying bummer int[]data={1,2,3};
7 Answers
Caleb Burks
3,093 PointsIt is looking for integers, not strings. When you add quotes around the numbers, it becomes a string. Try:
var data = [ 1, 2, 3 ];
Marc Cook
4,610 PointsHopefully this helps someone in the future, I thought I was crazy.
var data = [ '1', '2', '3' ];
//Note the numbers are in strings. -Numbers do not go in strings unless your stringing it together with something else. Am I right?
Amy Wurzbacher
9,022 PointsThank you so so much for this. I thought I was going insane!
Gabriel Bedell
9,860 Pointsvar data = [1,2,3];
Luis Reyes
11,719 PointsYes -> var data = [1,2,3]; worked. Thanks Gabriel
Cameron Mosser
7,102 PointsHi friends,
The formatting in Example 1 will be marked as incorrect for this challenge.
Example 1: var data = [ '1', '2', '3' ];
Be sure to format your answer to look like the bit of code highlighted in Example 2. Although the mentor used apostrophes in his array from the video just before this challenge, you will want to present your answer without them, (see Example 2 for correct formatting).
Example 2: var data = [ 1, 2, 3 ];
So what's different about Example 1 and Example 2? There are no apostrophes.
Hint: Apostrophes are the ' ' characters.
Simply omit the apostrophes from your array and the challenge should now pass...
Tom Nguyen
33,502 Pointssolution:
var data = [ 3, 4, 5 ];
var assorted = [ 'string', 3, true ] ;
Nicolas Hampton
44,725 PointsTry using the brackets to store the numbers, like
int[] data = [1,2,3];
You might also need to declare the size of the array beforehand to put anything in it,
int[] data = new int[3];
Nicolas Hampton
44,725 PointsActually, only use the brackets for declaring the size, then use the {} for the number instances.
MUZ140191 Prudence Goreraza
9,480 Pointsits not working