There are 2 ways to declare a function:

# Type 1
function name() {
}
 
# Type 2
name () {
}
function shadow() {
	if [ -e /etc/shadow ];
	then
		echo "Exist"
	else
		echo "File does not exist"
	fi
}
 
shadow

Function with parameters

Hello () {
	echo "Hello World $1 $2"
}
 
Hello Zara Ali

Function with local variables

Hello () {
	local name=$1
	echo "$name"
}
 
name="Tom"
echo "$name : Before"
 
Hello David
echo "$name : After"

Returning value from function

Hello () {
echo "Hello World $1 $2"
return 10
}
 
Hello Zara Ali
 
ret=$?
echo "Return value is $ret"