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
var sum = function () { | |
var result = 0; | |
arguments.forEach(function(number) { | |
result = result + number; | |
}); | |
return result; | |
}; |
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
const square = (...args) => args.map((arg) => arg * arg); | |
square(1, 2, 3, 4, 5); // => [1, 4, 9, 16, 25] |
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
var square = function(...args) { | |
return args.map(function(arg) { | |
return arg * arg; | |
}); | |
}; | |
square(1, 2, 3, 4, 5); // => [1, 4, 9, 16, 25] |
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
var square = function() { | |
var args = Array.prototype.slice.call(arguments); // convert arguments to array. | |
return args.map(function(arg) { | |
return arg * arg; | |
}); | |
}; | |
square(1, 2, 3, 4, 5); // => [1, 4, 9, 16, 25] |
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
var square = function () { | |
return arguments.map(function(arg) { | |
return arg * arg; | |
}); | |
}; | |
square(1, 2, 3, 4, 5); // => "TypeError: arguments.map is not a function |
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
/** | |
* When working with Named function expressions which one of the following is preffered and why? | |
*/ | |
/* Use the same name for the function and the variable its assigned to.*/ | |
var foo = function foo() { | |
return foo; | |
} | |
/* Use a different name for the function and the variable its assigned to. */ |
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
<div class="modal"> | |
modal content | |
</div> |
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
<div class="modal"> | |
<div class="modal-content"> | |
modal content | |
</div> | |
<div class="modal-overlay"></div> | |
</div> |
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
.modal { | |
background: black; | |
color: rgb(255, 255, 255); | |
height: 200px; | |
left: 50%; | |
position: relative; | |
text-align: center; | |
top: 50%; | |
transform: translate(-50%, 50%); | |
width: 200px; |
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
var variadic = function( fn ) { | |
var _slice = Array.prototype.slice; | |
var _length = fn.length; | |
if ( _length < 1 ) { | |
return fn; | |
} | |
if( _length === 1 ) { | |
return function () { |