Admissions Challenge Redux Flashcards
An […] is a collection of properties.
An object is a collection of properties. A set of properties are initialized in an object and can be added or removed.
Declare a variable named myArray and assign it to an empty array.
var myArray = [];
Populate myArray with two strings. Put your full name in the first string, and your Skype handle in the second.
myArray = [‘Ayan Said’, ‘validSkypeHandle’];
Declare a function named cutName. It should expect a parameter name.
*// you need to declare a function // the function should be named cutName // it should take one parameter, called name // the function body should remain empty for this step*
function cutName(name) {
{
// function body will eventually go here
cutName should return an array by breaking up the input string into individual words.
function cutName(name) {
// set variable equal to name, split on a space
var splitName = name.split(‘ ‘);
// return newly created variable
return splitName;
}
Declare a new variable named myInfo and assign it to an empty object literal.
var myInfo = {};
Add the following three key-value pairs to myInfo:
- Key: fullName, Value: The result of calling cutName on the name string within myArray.
- Key: skype, Value: The Skype handle within myArray.
- Key: github, Value: If you have a github handle, enter it here as a string. If not, set this to null instead.
var myInfo = {};
// Key: fullName, Value: The result of calling cutName on the name string within myArray.
myInfo.fullName = cutName(myArray[0]);
// Key: skype, Value: The Skype handle within myArray.
myInfo[‘skype’] = myArray[1];
// Key: github, Value: If you have a github handle, enter it here as a string. If not, set this to null instead.
myInfo.github = ‘githubHandle’;
// OR
myInfo.github = null;