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

Anton Arboleda
Anton Arboleda
2,018 Points

Hackreactor admissions coding challenge

First, declare an array named myArray Great! Now populate myArray with two strings. Put your full name in the first string, and your Skype handle in the second. Next, declare a function named cutName. It should take a string as an argument. cutName should return an array by breaking up the input string into individual words. For example "Douglas Crockford" should be returned as ["Douglas", "Crockford"] Make a new empty object literal named myData Add three key-value pairs to myData, by following these guidelines fullName : call cutName on the name string stored in myArray skype : refer to your Skype handle in myArray github : If you have a github handle, enter it as a string. If not, set this to null

2 Answers

Karolin Rafalski
Karolin Rafalski
11,368 Points

An error of unexpected identifier usually means a typo. Something like: Too many ; or too few } or a misplaced ( etc. etc.

It is really important to learn to understand what your errors are telling you.

The format of an object literal is

var myObject = {
key: value,
anotherKey: anotherValue
}

You should see that you are missing comma between your key value pairs.

Having been through a coding bootcamp, I must recommend that you study as much and as hard as you can before attending. Time will be your greatest enemy and whatever you can teach yourself beforehand will benefit you tremendously.

Karolin Rafalski, I haven't attended a bootcamp, but know quite a bit about them. Great last tip about knowing as much as you can going in. They're super demanding. For Anton Arboleda, best of luck with your pursuit and keep learning!

Anton Arboleda
Anton Arboleda
2,018 Points

var myArray; var myArray = ('0','1'); var myArray = ('AntonArboleda','aarboleda'); var cutName = function cutName(string) { return string.split(''); }

var myData = { fullName: cutName(myArray[0]) skype: myArray[1] github: 'aarboleda1';

}

Here is what I have come up with on my own. However, I keep getting "unexpected identifier" when typing in

skype: myArray[1] github: 'aarboleda1';

any suggestions?