-
-
Save chrisdhanaraj/3641aec8189527a0226f to your computer and use it in GitHub Desktop.
| // Write a function that returns its argument. | |
| // Write a function that takes a name and returns the length of the name. | |
| // Write a function that takes two numbers, adds them, and returns the result. | |
| // Write a function that takes an object and adds the key:value pair of "France" : "Paris" to it. Return the object. |
// Write a function that returns its argument.
// Write a function that takes a name and returns the length of the name.
// Write a function that takes two numbers, adds them, and returns the result.
// Write a function that takes an object and adds the key:value pair of "France" : "Paris" to it. Return the object
// Write a function that returns its argument.
// Testing the definition of a function
function answerOne(result) {
return result;
}
console.log(answerOne('the answer!'));
// returns 'the answer!'
// Write a function that takes a name and returns the length of the name.
// Testing string functions, .length
function nameLength(name) {
return name.length;
}
var danniLength = nameLength('danni');
// returns 4
// Write a function that takes two numbers, adds them, and returns the result.
// testing basic math
function add(x, y) {
return x + y;
}
// Write a function that takes an object and adds the key:value pair of "France" : "Paris" to it. Return the object
// testing object properties
function addValue(obj){
obj['France'] = 'Paris';
return obj;
}
obj = {
'United States' : 'Washington D.C.',
'Canada' : 'Ottawa'
}
addValue(obj);
console.log(obj);
/*
{
'United States' : 'Washington D.C.',
'Canada' : 'Ottawa',
'France': 'Paris'
}
*/
Danni: 30
Laura: 20