DEV Community

Lily Misra
Lily Misra

Posted on

Intro to Functions In JS 💻

Function Expressions

This function is pretty easy. Like for example if wanted to add two numbers together I would write this:

Name Necessities

In functions, we usually have to pass an argument(s) into the function. For example, console.log() can is one of the many arguments to put into a function. Also when writing a function you also put in a pair of (), parentheses tell the computer that it's a function. Without the parentheses then the function couldn't work.

Arrow-functions

There is a more modern function we can write called an arrow function. This is how to write one.

In arrow functions, the first thing we write is const which in Java Script is what we put to make a variable after that we name it and put our variable names, then our arrow to make one you put an equal sign then put greater than sign. Then put in your "return" statement which in this case we are only want the code to do one thing other wise we do put a return statement, but we can get more into that in someother time for now just stick with the basic way.

Anyways I hope you learned something! Let me know if you want a part 2!!! Thank you!!

@awesomecoder123

Top comments (7)

Collapse
 
dannohh profile image
dannohh

Most excellent!

Collapse
 
trollboy_j profile image
Jacko

You have a bright future ahead of you, keep up the good work! ^^

Collapse
 
shadowtime2000 profile image
shadowtime2000

Glad to see more kids programming and taking part of the developer community

Collapse
 
mrshawnhum profile image
Shawn Humphreys

Awesome job! Very wise beyond your youth!

Collapse
 
awesomecoder123 profile image
Lily Misra

Thank you! So much!

Collapse
 
codefinity profile image
Manav Misra

This is an awesome first post. Proud of you! 🤗

Collapse
 
awesomecoder123 profile image
Lily Misra

Thank you dad!