<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Solomon Obihan</title>
    <description>The latest articles on Forem by Solomon Obihan (@cstr55).</description>
    <link>https://forem.com/cstr55</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1064951%2Fe4de0c1d-7983-403d-a9e0-218b871e4778.jpg</url>
      <title>Forem: Solomon Obihan</title>
      <link>https://forem.com/cstr55</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/cstr55"/>
    <language>en</language>
    <item>
      <title>An introduction to Javascript and Its Functions.</title>
      <dc:creator>Solomon Obihan</dc:creator>
      <pubDate>Sat, 15 Apr 2023 21:54:33 +0000</pubDate>
      <link>https://forem.com/cstr55/an-introduction-to-javascript-and-its-functions-4kji</link>
      <guid>https://forem.com/cstr55/an-introduction-to-javascript-and-its-functions-4kji</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;What are functions?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;A function is a block of code created to carry out or execute a given set of tasks.&lt;/p&gt;

&lt;p&gt;Functions are critical to solving probems in most programming languages, and Javascript being the language of the web is no exception.&lt;/p&gt;

&lt;p&gt;An example of a function is :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function add (a,b) {
return a + b
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a function that enables us to find the sum of a and b.&lt;/p&gt;

&lt;p&gt;Now, let us go into the building blocks of a javascript functions.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;BUILDING BLOCKS OF A JAVASCRIPT FUNCTION&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;A function statement is usually made up of three buiiding blocks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The function keyword , &lt;code&gt;function&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The parameters enclosed in a bracket or parenthesis and separated by a comma when the parameters are more than one.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Javascript statements that defines the function, enclosed in a curly bracelets, {}.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now,let us look at the prevous example above:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function add (a,b) {
return a + b
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The parameters of the function above are &lt;code&gt;a and b&lt;/code&gt;;&lt;/p&gt;

&lt;p&gt;The Javascript statement is everything enclosed inside the curly brackets. It tells the function what to do. It's basically the characteristic of the function.&lt;/p&gt;

&lt;h2&gt;
  
  
  The &lt;code&gt;return&lt;/code&gt; statement
&lt;/h2&gt;

&lt;p&gt;When Javascript reaches the return statement, the function will stop executing and then it specifies a value to be returned to the function caller.&lt;br&gt;
It is said to have completed.&lt;/p&gt;

&lt;p&gt;Let us try a  proper example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const addFunc = function add(a, b){
return a + b
}
addFunc(3,2)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On execution, the &lt;code&gt;return&lt;/code&gt; statement gives us a value of 5, and the function is said to have completed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I hope we have succeeded in getting our feet wet with this brief introduction to functions in Javascript.&lt;/p&gt;

&lt;p&gt;This is just the beginning, and there are more advanced concepts in functions that we would be looking at in subsequent releases.&lt;/p&gt;

&lt;p&gt;In the meant-time, get into your text Editor and start practicing your functions.&lt;/p&gt;

&lt;p&gt;Practice makes perfect.&lt;/p&gt;

</description>
      <category>webdev</category>
    </item>
  </channel>
</rss>
