Reputation: 31
Problem:
["Douglas", "Crockford"]
fullName
Value: The result of calling cutName on the name string within myArray.skype
Value: The Skype handle within myArray.github
Value: If you have a github handle, enter it here as a string. If not, set this to null instead.My code
var myArray = ['Isaiah Sias', 'isaiahsias15689'];
function cutName(name){
var splitString = name.split(myArray[0]' ');
return splitString;
}
var myInfo{
fullName = cutName(myArray[0]),
skype = myArray[1],
github='@kakashihatake',
};
Once again I am not sure where I am messing up. I have been working on this problem for a few days now and find myself a little frustrated.
Upvotes: 2
Views: 1931
Reputation: 4370
var myArray = ['Isaiah Sias', 'isaiahsias15689'],
github = '@kakashihatake';
function toObject(){
return {
fullName: myArray[0].split(' '),
skype: myArray[1],
github: github
}
}
console.log(toObject());
Upvotes: -1
Reputation: 22247
You are very close, you have made a small mistake in the cutName function.
The string.split method takes only 1 parameter, the string to split by. You've tried to pass in the array element as well. Get rid of it! (Keep in mind that the thing we are splitting, name
, has been assigned the array element as its value during the function call)
var splitString = name.split(myArray[0]' ');
becomes
var splitString = name.split(' ');
One other issue, you'll need to change your object definition a bit. You have a missing =
between myInfo and the start of the object literal. And, when setting property names and values in an object literal you need to use colon instead of equals, so your object
var myInfo{
fullName = cutName(myArray[0]),
skype = myArray[1],
github='@kakashihatake',
};
becomes
var myInfo = {
fullName: cutName(myArray[0]),
skype: myArray[1],
github: '@kakashihatake'
};
Upvotes: 2