<?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>DEV Community: Pharaoh-ke</title>
    <description>The latest articles on DEV Community by Pharaoh-ke (@pharaoh_ke).</description>
    <link>https://dev.to/pharaoh_ke</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%2F964472%2F2bc9c137-91a6-4214-b594-18d8bdf963d2.png</url>
      <title>DEV Community: Pharaoh-ke</title>
      <link>https://dev.to/pharaoh_ke</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pharaoh_ke"/>
    <language>en</language>
    <item>
      <title>introduction to Javascript</title>
      <dc:creator>Pharaoh-ke</dc:creator>
      <pubDate>Tue, 08 Nov 2022 20:10:56 +0000</pubDate>
      <link>https://dev.to/pharaoh_ke/introduction-to-javascript-15p7</link>
      <guid>https://dev.to/pharaoh_ke/introduction-to-javascript-15p7</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;MOSE&lt;/p&gt;
&lt;h2&gt;
  
  
  History of JavaScript
&lt;/h2&gt;

&lt;p&gt;JavaScript was created at Netscape Communications ****by Brendan Eich in 1995. Netscape and Brendan Eich designed JavaScript as a scripting language for Netscape Navigator which was a leading web browser in the 1990s.&lt;br&gt;
JavaScript's first name was Mocha. After that, it was known as Live Script and later known as JavaScript.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  JavaScript placement
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript can be placed in a html file  in the  body section using a script tag and placing you JavaScript code within the tags.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body&amp;gt;
&amp;lt;script type="text/javascript"&amp;gt;
&amp;lt;!--
document.write("Hello World")
//--&amp;gt;
&amp;lt;/script&amp;gt;
&amp;lt;p&amp;gt;This is web page body &amp;lt;/p&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Can also be placed in an external file source with an extension ".js" e.g &lt;strong&gt;filename.js&lt;/strong&gt; then include it in a html code using &lt;strong&gt;script&lt;/strong&gt; tag and **src **attribute
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;script type="text/javascript" src="filename.js" &amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
.......
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  JavaScript Variables
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;JavaScript has variables that you can declare with&lt;br&gt;
the optional var keyword.&lt;code&gt;var age="21years"&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JavaScript variable shouldn't start with numbers but with letters or underscore. i.e can be declared as &lt;code&gt;_name="Moses"&lt;/code&gt; and &lt;code&gt;name="Moses"&lt;/code&gt; but *&lt;em&gt;not *&lt;/em&gt;&lt;code&gt;1name="Moses"&lt;/code&gt; which is an invalid variable&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;They are case sensitive. i.e &lt;code&gt;Name&lt;/code&gt; and &lt;code&gt;name&lt;/code&gt; are two different variables.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Don`t use reserved words as variables&lt;br&gt;
NB: &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Operators
&lt;/h2&gt;

&lt;p&gt;let's declare variables&lt;br&gt;
&lt;code&gt;A = 10&lt;br&gt;
B = 20&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. +(Addition)&lt;/strong&gt;&lt;br&gt;
Adds two operands. Ex:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
result = a + b;&lt;br&gt;
document.write("a + b = ");&lt;br&gt;
document.write(result);&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
will give &lt;br&gt;
&lt;code&gt;a + b = 43&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;NOW TRY USING THE OTHER OPERATORS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. -(Subtraction)&lt;/strong&gt;&lt;br&gt;
Subtracts the second operand from the first&lt;br&gt;
Ex: A - B will give -10&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. *(Multiplication)&lt;/strong&gt;&lt;br&gt;
Multiply both operands&lt;br&gt;
Ex: A * B will give 200&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. / (Division)&lt;/strong&gt;&lt;br&gt;
Divide the numerator by the denominator&lt;br&gt;
Ex: B / A will give 2&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. % (Modulus)&lt;/strong&gt;&lt;br&gt;
Outputs the remainder of an integer division&lt;br&gt;
Ex: B % A will give 0&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. ++ (Increment)&lt;/strong&gt;&lt;br&gt;
Increases an integer value by one&lt;br&gt;
Ex: A++ will give 11&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. -- (Decrement)&lt;/strong&gt;&lt;br&gt;
Decreases an integer value by one&lt;br&gt;
Ex: A-- will give 9&lt;/p&gt;
&lt;h2&gt;
  
  
  Comparison Operetors
&lt;/h2&gt;

&lt;p&gt;A = 10&lt;br&gt;
B = 20&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. == (Equal&lt;/strong&gt;)&lt;br&gt;
Checks if the value of two operands are equal or not, if yes, then &lt;br&gt;
the condition becomes true.&lt;br&gt;
Ex:&lt;br&gt;
&lt;code&gt;result = (a == b);&lt;br&gt;
document.write("(a == b) =&amp;gt; ");&lt;br&gt;
document.write(result);&lt;/code&gt;&lt;br&gt;
THE OUTPUT FOR THE CODE WILL BE&lt;br&gt;
&lt;code&gt;(a == b) =&amp;gt; false&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. != (Not Equal)&lt;/strong&gt;&lt;br&gt;
Checks if the value of two operands are equal or not, if the values &lt;br&gt;
are not equal, then the condition becomes true.&lt;br&gt;
Ex: (A != B) is true.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. &amp;gt; (Greater than)&lt;/strong&gt;&lt;br&gt;
Checks if the value of the left operand is greater than the value of the right operand, if yes, then the condition becomes true.&lt;br&gt;
Ex: (A &amp;gt; B) is not true.&lt;br&gt;
&lt;strong&gt;4. &amp;lt; (Less than)&lt;/strong&gt;&lt;br&gt;
Checks if the value of the left operand is less than the value of &lt;br&gt;
the right operand, if yes, then the condition becomes true.&lt;br&gt;
Ex: (A &amp;lt; B) is true.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. &amp;gt;= (Greater than or Equal to)&lt;/strong&gt;&lt;br&gt;
Checks if the value of the left operand is greater than or equal to &lt;br&gt;
the value of the right operand, if yes, then the condition becomes &lt;br&gt;
true.&lt;br&gt;
Ex: (A &amp;gt;= B) is not true.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. &amp;lt;= (Less than or Equal to)&lt;/strong&gt;&lt;br&gt;
Checks if the value of the left operand is less than or equal to the &lt;br&gt;
value of the right operand, if yes, then the condition becomes &lt;br&gt;
true.&lt;br&gt;
Ex: (A &amp;lt;= B) is true.&lt;/p&gt;
&lt;h2&gt;
  
  
  Conditional statements
&lt;/h2&gt;
&lt;h2&gt;
  
  
  if else statement
&lt;/h2&gt;

&lt;p&gt;The ‘if’ statement is the fundamental control statement that allows JavaScript to make decisions and execute statements conditionally.&lt;br&gt;
&lt;strong&gt;syntax&lt;/strong&gt;&lt;br&gt;
`&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (expression){
 Statement(s) to be executed if expression is true
}else{
Statement(s) to be executed if expression is false
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;script type="text/javascript"&amp;gt;
&amp;lt;!--
var age = 20;
if( age &amp;lt; 18 ){
 document.write("&amp;lt;b&amp;gt;You are not qualified to enter the site&amp;lt;/b&amp;gt;")
}else{
welcome to the site
}
//--&amp;gt;
&amp;lt;/script&amp;gt;
&amp;lt;p&amp;gt;Try using a different variable value&amp;lt;/p&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;You are not qualified to enter the site.&lt;br&gt;
Set the variable to a different value and ten try...&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
**&lt;/p&gt;
&lt;h2&gt;
  
  
  else if statement
&lt;/h2&gt;

&lt;p&gt;else if statement allows JavaScript to make a correct decision out of several conditions.&lt;br&gt;
&lt;strong&gt;syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (expression 1){
 Statement(s) to be executed if expression 1 is true
}else if (expression 2){
 Statement(s) to be executed if expression 2 is true
}else if (expression 3){
 Statement(s) to be executed if expression 3 is true
}else{
 Statement(s) to be executed if no expression is true
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;script type="text/javascript"&amp;gt;
&amp;lt;!--
var series = "outpost";
if( series == "blacklist" ){
 document.write("&amp;lt;b&amp;gt;TheBlacklist&amp;lt;/b&amp;gt;");
}else if( series == "witcher" ){
 document.write("&amp;lt;b&amp;gt;The Witcher&amp;lt;/b&amp;gt;");
}else if( series == "outpost" ){
 document.write("&amp;lt;b&amp;gt;The Outpost&amp;lt;/b&amp;gt;");
}else{
 document.write("&amp;lt;b&amp;gt;Not Available&amp;lt;/b&amp;gt;");
}
//--&amp;gt;
&amp;lt;/script&amp;gt;
&amp;lt;p&amp;gt;Try using a different variable value&amp;lt;/p&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;output&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
The Outpost&lt;br&gt;
Try using a different variable value&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
