-
-
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. |
//1
var test =['argument'];
test
//2
var name = ['Laura'];
name.length ??don't remember how to return length
//3
var number1 = ['42'];
var number2 = ['23'];
function to add both
number1 + number2
//4
var portal = {
'United Kingdom' : 'London'
};
var cube = {
'France' : 'Paris'
};
function turret()
to add functions
Danni: 30
Laura: 20
// 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'
}
*/
// #1
var firstVariable = function() {
console.log('hi there!');
}
function test(element) {
test(element);
}
test(firstVariable);
// ANSWER: hi there!
// #2
var name = 'danni';
name.length
// ANSWER: 5
// #3
var one = 1;
var two = 2;
one + two = 3
// ANSWER: 3
// #4