A function is a structured data type that is a container that stores values. Think of that dream apartment you want. You will need furniture inside your new beautiful home, so you have a choice to ditch the old stuff or pack the stuff you want. Either way you have to pack certain belongings because its an essential need.
Its packing day and you need boxes. You realize that you need a storage unit because your apartment did not include this amenity. JavaScript is your storage unit. Your deciding that you want to decorate your apartment with new artwork and you want to pack and store the wall décor(artwork) that is currently in your apartment. Lets pack the wall décor so that we can move it into storage.
We will use a string literal to assign a value. A string literal is characters placed inside two backticks '' or quotation marks "". This is going to help us create a structured data type called a "function" I am going to demonstrate how "Let" can be used.
Using Let helps us identify the variable. Let allows us to assign values inside a variable and enables us to have the ability to change it or manipulate the code later on.
Const is another identifier that allows us to assign a value to a variable but in this case you can not change it later on. Now we will assign a value to a variable. You have now taken the first piece of art off of the wall called "Fuego Flores". I am a huge Basquiat fan as well! Your deciding that you want to place all your artwork on a specific shelf inside the storage unit. That shelf is called art
let art = 'Fuego Flores'
the = sign works an assignment operator that helps us assign a value to a variable
Now we can type art in the terminal and see what is returns. We get back 'Fuego Flores'. In simpler words, we would need to type the variable in the console to return the value. Go ahead and type the variable art and it will return the value 'Fuego Flores'
What we did was assign the value 'Fuego Flores' to the variable art. art is the folder or in this case the storage location(shelf) inside our storage unit. Fuego Flores is now stored inside of that folder or in this case on the shelf in that particular location(art) inside the storage unit.
Now lets go back to our variable that now has a value inside.
let art = 'Fuego Flores'. This is now a statement( a set of instructions but doesn't return the value 'Fuego Flores' just yet).
If we run this it will come back as undefined. Why is that? Well we created our statement which is the instructions to produced the value but has not returned what we are asking in the statement because we have not instruct it to do so. I know you're wondering , well how do I create a code that gives the statement instructions to return the value 'Fuego Flores'.
Check out my upcoming blog " Declaring Functions”.