Home > Web Front-end > JS Tutorial > body text

days of Miva: Day 9

WBOY
Release: 2024-08-29 14:40:40
Original
857 people have browsed it

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.

 days of Miva: Day 9

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

 days of Miva: Day 9

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:

 days of Miva: Day 9

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

 days of Miva: Day 9

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.

 days of Miva: Day 9

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

The above is the detailed content of days of Miva: Day 9. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!