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 Foundations Arrays Creating Arrays

Javascript arrays - how to put placeholders into arrays

Javascript Stage 4 - Arrays Callenge 2

says:

Set the 'guides' that has placeholders for 42 elements but has no values stored in it.

var guides = [];

The video doesn't show how to put a "placeholder" into an array. How do you do that?

thanks in advance

arrays.js
var mixture = ['string1', 'string2', 'string3', 1, 2, false];
var guides = [];

2 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Chris;

This should work:

var guides = new Array(42);

Hope it helps,

Ken

Thanks, Ken. It didn't work until I capitalized the letter "A" in "Array". The challenge's wording doesn't make sense. The video makes no mention of "placeholder". When the video goes over "new Array" - it explains that the number put in parentheses sets the "length" of the variable. To me the "length" means how many characters - no placeholders.

Thanks anyway for your help.

Hugo Paz
Hugo Paz
15,622 Points

Hi Chris,

You just need to create an array with 42 positions.

var guides = new Array(42);

Thanks, Hugo. I got thrown by wording. "placeholder" and "positions" were never mentioned in the video. "length" to me always referred to "number of characters".