Skip to content

Instantly share code, notes, and snippets.

@hacktember
Created November 27, 2018 04:28
Show Gist options
  • Save hacktember/c85e046cef6325d383a80b93102925d3 to your computer and use it in GitHub Desktop.
Save hacktember/c85e046cef6325d383a80b93102925d3 to your computer and use it in GitHub Desktop.
Example function in JavaScript
function mergeTwoNamesIntoOneWithoutSpaces(speciesOne, speciesTwo) {
// speciesOne and speciesTwo are variables; by defining what happens to the
// variables in a function, it lets us transform anything (of a compatible data type)
// that we pass into the function
// whatever we "return" is what the function spits out
return speciesOne + speciesTwo;
}
var animalOne = "Pig";
var animalTwo = "Dog";
var animalThree = mergeTwoNamesIntoOneWithoutSpaces(animalOne, animalTwo); // animalThree should be "PigDog"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment