Last active
August 29, 2015 14:07
-
-
Save chrisdhanaraj/3641aec8189527a0226f to your computer and use it in GitHub Desktop.
JS Jamz Quiz #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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. |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
// 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'
}
*/