Skip to content

Instantly share code, notes, and snippets.

@blentz100
Last active April 29, 2022 15:21
Show Gist options
  • Save blentz100/0c54637fba3d93de5841ede203ff0f95 to your computer and use it in GitHub Desktop.
Save blentz100/0c54637fba3d93de5841ede203ff0f95 to your computer and use it in GitHub Desktop.
Intro to Javascript Week 3 and Week 4 code examples of functions
//regular function example with a return
function addition(number){
return number + 100;
}
console.log(addition(66))
//arrow function example
const additionV2 = number => number + 100;
console.log(additionV2(66))
//function example with no return
function additionTwo(number){
console.log(number + 12)
}
additionTwo(55)
//function example with a callback function
function additionThree(callbackFunction){
callbackFunction("hello world i'm in a callback")
}
additionThree(console.log)
//function with no params
function broadcastAlert(){
console.log("Weather Advisory Alert!!!! Stay indoors, Storm coming")
}
broadcastAlert();
// argument and parameter
function exampleFunction(iAmParameter){
console.log(iAmParameter)
}
exampleFunction("iAmAnArgument")
//arrow function with a loop, and no parameters
const arrowLoop = () => {
for(let i = 0; i < 10; i++){
console.log("Hello I'm in a loop in an arrow func " + i)
}
}
arrowLoop()
@Masheen88
Copy link

Hello

@blentz100
Copy link
Author

Hey @Masheen88 ! Thanks for coming to office hours today1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment