Skip to content

Instantly share code, notes, and snippets.

@imwithsam
Last active October 13, 2015 15:35
Show Gist options
  • Save imwithsam/306c7b56858b4df75934 to your computer and use it in GitHub Desktop.
Save imwithsam/306c7b56858b4df75934 to your computer and use it in GitHub Desktop.
Echo
function echo1(myArray) {
if (Array.isArray(myArray)) {
myArray.forEach(function(element) {
console.log(element);
});
}
}
function echo2() {
for(var i = 0; i < arguments.length; i++) {
console.log(arguments[i]);
}
}
echo1();
echo1(['one']);
echo1(['one', 'two', 'three']);
echo2();
echo2('one');
echo2('one', 'two', 'three');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment