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 trialabdi ali
10,920 Pointshelp me to solve these question is not in the course.
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
3 Answers
Daniel Newman
Courses Plus Student 10,715 Points// First, declare an array named myArray Great!
var myArray = [];
// Now populate myArray with two strings.
myArray = ["first", "second"];
// Put your full name in the first string, and your Skype handle in the second.
myArray = ["Abdi Ali", "AbdiAli"]
// Next, declare a function named cutName. It should take a string as an argument.
var cutName = function(str) {
}
// cutName should return an array by breaking up the input string into individual words.
// For example "Douglas Crockford"
// should be returned as["Douglas", "Crockford"]
var cutName = function(str) {
return str.split(" ");
// Or use regexps [.match(/\w+/g)] to throw away spaces
// and non-literal characters. Example:
//
"side the char class is treated as a literal + and not as a meta char. Using * will capture zero or more spaces".match(/\w+/g);
}
// 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
var myData = {
fullName: cutName(myArray[0]),
skype: myArray[1],
github: myArray[2] || null
}
Lee Zamastil
21,628 PointsAs of this moment⦠this here's just above my level. Which makes it perfect for study. Thanks for taking the time!
ousmane Kamakate
5,280 PointsThanks a lot for your help, doubt i will get admitted but i appreciate the code that you shared. Thanks a lot
abdi ali
10,920 Pointsthanks
Roland Cedo
21,261 PointsHack Reactor challenges, love it.
abdi ali
10,920 Pointsabdi ali
10,920 Pointsthis how i solved it.
var myArray = ["abdi mohamud ali", "abdi.mohamud.ali"];
function cutName(string) { return string + " "; }
var myDate = { fullName: "cutName(myArray[0])", skype: "cutName(myArray[1]", github: "null" };