Last active
April 29, 2022 15:21
-
-
Save blentz100/0c54637fba3d93de5841ede203ff0f95 to your computer and use it in GitHub Desktop.
Intro to Javascript Week 3 and Week 4 code examples of functions
This file contains 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
//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() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello