100 days of Miva: Day 9

Day 9 of the 100 days of Miva coding challenge. Big progress has been made on my understanding of JavaScript.

Today, I learned about functions on JavaScript. Functions are very useful in JavaScript as they allow us to reuse code and also avoid mistake…


This content originally appeared on DEV Community and was authored by Abdulsamod

Day 9 of the 100 days of Miva coding challenge. Big progress has been made on my understanding of JavaScript.

Today, I learned about functions on JavaScript. Functions are very useful in JavaScript as they allow us to reuse code and also avoid mistakes due to code duplication. Thanks to W3schools, I was able to learn and practice functions and operations related to them. Let's dive in!

Creating Functions
Functions are created by using the function keyword, followed by parenthesis containing the parameters required for executing the function. The return keyword is used to state which operation is to be performed on the parameter(s) and what value to return to the user.

Creating Functions

Using Functions outputs as variable values
Outputs of functions can be assigned to variable names after the function has been executed.

Variable Values

Functions have various uses and can be used to perform different types of operations ranging from arithmetic operations, logical operations and executing conditional statements. Here is an example of a function used to convert units:

Unit Conversion

Values obtained from these operations can be embedded in HTML programs that require values obtained from these functions.

Embedding outputs in texts

Local Variables
In JavaScript, variables declared within a function are known as local variables and do not exist outside of the function. Hence, a new variable can be declared with the same name outside of the function which is normally not allowed.

Local Variables

Functions are very important in JavaScript as they make coding easier and cleaner. They allow code reusability and serve as mini libraries where outputs can be pulled for use in other parts of code.

That's it on JavaScript Functions. Hoping to explore more and share with you in the coming days! Source code can be seen here: https://github.com/Abdul-Samod/100daysofMiva/blob/ce61cd46cefb40058a83276484d45b1b27c27a38/javascript_prac2.html


This content originally appeared on DEV Community and was authored by Abdulsamod


Print Share Comment Cite Upload Translate Updates
APA

Abdulsamod | Sciencx (2024-08-28T22:47:56+00:00) 100 days of Miva: Day 9. Retrieved from https://www.scien.cx/2024/08/28/100-days-of-miva-day-9/

MLA
" » 100 days of Miva: Day 9." Abdulsamod | Sciencx - Wednesday August 28, 2024, https://www.scien.cx/2024/08/28/100-days-of-miva-day-9/
HARVARD
Abdulsamod | Sciencx Wednesday August 28, 2024 » 100 days of Miva: Day 9., viewed ,<https://www.scien.cx/2024/08/28/100-days-of-miva-day-9/>
VANCOUVER
Abdulsamod | Sciencx - » 100 days of Miva: Day 9. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/08/28/100-days-of-miva-day-9/
CHICAGO
" » 100 days of Miva: Day 9." Abdulsamod | Sciencx - Accessed . https://www.scien.cx/2024/08/28/100-days-of-miva-day-9/
IEEE
" » 100 days of Miva: Day 9." Abdulsamod | Sciencx [Online]. Available: https://www.scien.cx/2024/08/28/100-days-of-miva-day-9/. [Accessed: ]
rf:citation
» 100 days of Miva: Day 9 | Abdulsamod | Sciencx | https://www.scien.cx/2024/08/28/100-days-of-miva-day-9/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.