Function Declarations

👨‍💼 We need a way to group code into reusable units. Function declarations let us define named functions that we can call whenever we need them.
The syntax:
function functionName() {
	// code to run when called
}

// Call the function
functionName()
🐨 Open and:
  1. Create a function called greet that logs "Hello, world!"
  2. Create a function called sayGoodbye that logs "Goodbye!"
  3. Call both functions
💰 Example:
function celebrate() {
	console.log('🎉 Hooray!')
}

celebrate() // Logs: 🎉 Hooray!
celebrate() // Logs: 🎉 Hooray! (again!)

Please set the playground first

Loading "Function Declarations"
Loading "Function Declarations"