<?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: mohandass</title>
    <description>The latest articles on Forem by mohandass (@mohandassmani).</description>
    <link>https://forem.com/mohandassmani</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%2F3800143%2F7b7ad166-c397-4ffc-a2d2-7c0fc07e8f89.png</url>
      <title>Forem: mohandass</title>
      <link>https://forem.com/mohandassmani</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mohandassmani"/>
    <language>en</language>
    <item>
      <title>JavaScript scenario questions (variables,operators,conditional statements)</title>
      <dc:creator>mohandass</dc:creator>
      <pubDate>Sat, 18 Apr 2026 16:31:50 +0000</pubDate>
      <link>https://forem.com/mohandassmani/javascript-scenario-questions-variablesoperatorsconditional-statements-35ii</link>
      <guid>https://forem.com/mohandassmani/javascript-scenario-questions-variablesoperatorsconditional-statements-35ii</guid>
      <description>&lt;h2&gt;
  
  
  1. You are building a login system.Store username and password in variable and check whether are filled.
&lt;/h2&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;messi&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;123456&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;please give user name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;please give password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;login successful&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
login successful&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Create variable to store a product's name,price,and stock.Print message like:
&lt;/h2&gt;

&lt;p&gt;"iPhone cost ₹60000 and only 5 left in stock"&lt;/p&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;iPhone 16&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;₹60000&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;stock&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;  &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; costs &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; and only &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;stock&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; left in stock.`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;/p&gt;

&lt;p&gt;iPhone 16 costs ₹60000 and only 5 left in stock.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Store a student's marks in 3 subjects and calculate total.
&lt;/h2&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;marks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;70&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;marks1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;marks2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;marks&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;marks1&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;marks2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;total:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
total: 210&lt;/p&gt;
&lt;h2&gt;
  
  
  4. Swap two numbers without using a their variable.
&lt;/h2&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
7 //a&lt;br&gt;
10 //b&lt;/p&gt;
&lt;h2&gt;
  
  
  5. Create a variable that store whether a user is logged in or not and show a welcome message.
&lt;/h2&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;isLoggedin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;isLoggedin&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;welcome!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;please log in to continue&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
WELCOME!&lt;/p&gt;
&lt;h2&gt;
  
  
  6. An e-commerce website gives 10% discount.Calculate final price.-(TBD)
&lt;/h2&gt;
&lt;h2&gt;
  
  
  7. Check whether a number is even or odd using operator.
&lt;/h2&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;19&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Even Number&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Odd Number&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
Odd Number&lt;/p&gt;
&lt;h2&gt;
  
  
  8. Compare two passwords entered by user.
&lt;/h2&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;abc123&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;password1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;abc123&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nx"&gt;password1&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Matched&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Not Matched&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
Matched &lt;/p&gt;
&lt;h2&gt;
  
  
  9.A person is eligible to vote if age &amp;gt;=18.Write condition.
&lt;/h2&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;personAge&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;personAge&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Is Eligible for Vote&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Is Not Eligible for Vote&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
Is Not Eligible for Vote&lt;/p&gt;
&lt;h2&gt;
  
  
  10. Use logical AND to check:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;User is logged in&lt;/li&gt;
&lt;li&gt;User is admin 
Then allow dashboard access.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;isLoggedin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;admin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;isLoggedin&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;admin&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Allow dashboard access&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; Not allow dashboard access&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
Allow dashboard access&lt;/p&gt;
&lt;h2&gt;
  
  
  11. Create a function that calculate total cart amount.
&lt;/h2&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;cart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;450&lt;/span&gt;&lt;span class="p"&gt;,];&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;amt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;acc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;acc&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;totalamt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;amt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Total :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;totalamt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
Total : 1250&lt;/p&gt;
&lt;h2&gt;
  
  
  12. Create a function to greet a user by name.
&lt;/h2&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;MESSI&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`WELCOME! &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; `&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
WELCOME! MESSI &lt;/p&gt;
&lt;h2&gt;
  
  
  13. Create a function to convert Celsius and Fahrenheit.
&lt;/h2&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;fahrenheit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;celsius&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;celsius&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;32&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;°F&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;fahrenheit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
50°F&lt;/p&gt;
&lt;h2&gt;
  
  
  14. Create a function that returns the  largest of two numbers.
&lt;/h2&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;findlargest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;largnum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;findlargest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;largnum&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
100 //b&lt;/p&gt;
&lt;h2&gt;
  
  
  15. Create a function to calculate EMI for a loan.-(TBD)
&lt;/h2&gt;
&lt;h2&gt;
  
  
  16. If user role is "admin" show admin panel,else show user dashboard.
&lt;/h2&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;admin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;admin&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Show admin panel&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Show user dashbord&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
Show user dashbord&lt;/p&gt;
&lt;h2&gt;
  
  
  17. check if number is positive,negative, or zero.
&lt;/h2&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;checknumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;positive Number&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;negative Number&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Zero&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;checknumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
positive Number&lt;/p&gt;
&lt;h2&gt;
  
  
  18. Check if a year is leap year.
&lt;/h2&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;year&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2004&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;year&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;leap year&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Not a leap year&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
leap year&lt;/p&gt;
&lt;h2&gt;
  
  
  19. Movie ticket pricing: Child(&amp;lt;12)-₹100 Adult-₹200.
&lt;/h2&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Movie ticket price ₹100&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Movie ticket price ₹200&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
Movie ticket price ₹200&lt;/p&gt;
&lt;h2&gt;
  
  
  20. If marks &amp;gt;=90-Grade A  75-Grade B else-Fail.
&lt;/h2&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;mark&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;mark&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Grae A&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;mark&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;75&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Grade B&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Fail&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
Grade B&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Object &amp; Array Scenario Quections</title>
      <dc:creator>mohandass</dc:creator>
      <pubDate>Fri, 17 Apr 2026 19:21:45 +0000</pubDate>
      <link>https://forem.com/mohandassmani/object-array-scenario-quections-2gll</link>
      <guid>https://forem.com/mohandassmani/object-array-scenario-quections-2gll</guid>
      <description>&lt;p&gt;&lt;strong&gt;1. User Profile Update&lt;/strong&gt;&lt;br&gt;
You have:&lt;br&gt;
const user = {&lt;br&gt;
name:"vijay",&lt;br&gt;
age:25,&lt;br&gt;
email:"&lt;a href="mailto:vijay@gmail.com"&gt;vijay@gmail.com&lt;/a&gt;"};&lt;/p&gt;

&lt;p&gt;Update email and a new property isActive = true.&lt;/p&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;vijay&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;vijay@gmail.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
 &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mohan2004@gmail.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
 &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isActive&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
 &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
{&lt;br&gt;
  name: 'vijay',&lt;br&gt;
  age: 25,&lt;br&gt;
  email: '&lt;a href="mailto:mohan2004@gmail.com"&gt;mohan2004@gmail.com&lt;/a&gt;',&lt;br&gt;
  isActive: true&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Shopping Cart Total&lt;/strong&gt;&lt;br&gt;
You have:&lt;br&gt;
const cart = [&lt;br&gt;
    {name: "shirt",price : 500},&lt;br&gt;
    {name: "shoes",price : 1500},&lt;br&gt;
    {name :"cap", price : 300}&lt;/p&gt;

&lt;p&gt;];&lt;/p&gt;

&lt;p&gt;Calculate total price.&lt;/p&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;cart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;shirt&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="na"&gt;price&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;shoes&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="na"&gt;price&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1500&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cap&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;price&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;total :&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
total : 2300&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Find Specific Object&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You have:&lt;br&gt;
const user = [&lt;br&gt;
    {name: "vijay", age: 25},&lt;br&gt;
    {name: "Arun", age: 30},&lt;br&gt;
    {name: "Kumar", age: 28}&lt;br&gt;
];&lt;/p&gt;

&lt;p&gt;From an array of users,find the user whose name is "Arun".&lt;/p&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;vijay&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Arun&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Kumar&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;28&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;nam&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Arun&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;nam&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
[ { name: 'Arun', age: 30 } ]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Add item to array&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You have:&lt;br&gt;
const products = [{name: "shirt", price:1500},&lt;br&gt;
{name: "shoes", price:1500}];&lt;/p&gt;

&lt;p&gt;Add a new product dynamically to an existing product array remove a product with the name "shoes" from the array.From a product list,return only items with price &amp;gt; 1000.&lt;/p&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;products&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;shirt&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;price&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;1500&lt;/span&gt;&lt;span class="p"&gt;},{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;shoes&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;price&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;1500&lt;/span&gt;&lt;span class="p"&gt;}];&lt;/span&gt;

&lt;span class="nx"&gt;products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;watch&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;price&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;1700&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;



&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;!=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;shoes&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
[ { name: 'shirt', price: 1500 }, { name: 'watch', price: 1700 } ]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Count items in object&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You have:&lt;br&gt;
const fruits = {&lt;br&gt;
    apple:2,&lt;br&gt;
    banana:5,&lt;br&gt;
    mango:3&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;Find the total number of fruits.&lt;/p&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fruits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;apple&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;banana&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;mango&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newarr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;arr1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;total&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;newarr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fruits total:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
fruits total: 10&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Convert array to object&lt;/strong&gt;&lt;br&gt;
You have:&lt;/p&gt;

&lt;p&gt;const users = ["vijay","arun","kumar"];&lt;/p&gt;

&lt;p&gt;Convert into:&lt;br&gt;
{ vijay:true,&lt;br&gt;
Arun:true,&lt;br&gt;
Kumar:true }&lt;/p&gt;

&lt;p&gt;PROGRAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;vijay&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;arun&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;kumar&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;true&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromEntries&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
{ vijay: 'true', arun: 'true', kumar: 'true' }&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>Javascript Array iteration methods</title>
      <dc:creator>mohandass</dc:creator>
      <pubDate>Wed, 15 Apr 2026 19:27:31 +0000</pubDate>
      <link>https://forem.com/mohandassmani/javascript-array-iteration-methods-n6e</link>
      <guid>https://forem.com/mohandassmani/javascript-array-iteration-methods-n6e</guid>
      <description>&lt;ul&gt;
&lt;li&gt;Array iteration method in javascript are built in tools allows you to operate on every item in an array,One at a time.The most of the method a callback function as a arguments.Which is execute for each elements in a array.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Array Iteration Methods&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Array forEach&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array map()&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array flatMap()&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array filter()&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array reduce()&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array reduceRight()&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array every()&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array some()&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array from()&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array keys()&lt;/code&gt;-(TBD)&lt;br&gt;
&lt;code&gt;Array entries()&lt;/code&gt;-(TBD)&lt;br&gt;
&lt;code&gt;Array with()&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array Spread (...)&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array Rest (...)&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. forEach()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The forEach() method calls a function (a callback function) once for each array element.It's used for side effects, and returns undefined(void).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnawa1zy1s5v6nwptdoxt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnawa1zy1s5v6nwptdoxt.png" alt=" " width="800" height="188"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that the function is take 3 arguments &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The item value&lt;/li&gt;
&lt;li&gt;The item index&lt;/li&gt;
&lt;li&gt;The array itself&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Above the example used only the value arguments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Array map()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;map()&lt;/code&gt; method create a new array performing a function on each array elements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The map() method dose not execute the function for array elements without values.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The map() method is a non-mutating method,meaning it dose not change the original array.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpr3sw59aw4r3pirfpm1b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpr3sw59aw4r3pirfpm1b.png" alt=" " width="693" height="203"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note the function is take 3 arguments:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The item value&lt;/li&gt;
&lt;li&gt;The item index&lt;/li&gt;
&lt;li&gt;The array itself&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Above the example callback function used only the value parameter.The index and array it can be your choice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. flatMap()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;flatMap()&lt;/code&gt; method is built in array function that combines two operations into a single efficient.that is mapping and flattening,the mapping each elements using a callback function.And then flattening the result by the exactly one level.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This method is return the new array and dose not modify the original array.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr4bwdavqzulgpcvykvyg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr4bwdavqzulgpcvykvyg.png" alt=" " width="712" height="155"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
[ 8, 18, 10, 14, 6 ]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. filter()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;filter()&lt;/code&gt; method is create a new array containing only the elements from an existing array that pass a specific test(condition)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It's is the iterative method,that meaning it's runs a provided function for every element in the array &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This method is returns a new array.it dose not change the original array &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F545rod7pg059xwoyh66t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F545rod7pg059xwoyh66t.png" alt=" " width="785" height="285"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The example create a new array from elements with a value lager than 35 &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Note that the function take three arguments:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The item value&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The item index&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The array itself&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Above the example callback function used only the value,The index and array parameters can be omitted.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Output:&lt;br&gt;
[ 90, 50, 70 ]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. reduce()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;reduce()&lt;/code&gt; method runs a function on each array element to produce a single value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This method dose not change the original array &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnyo6ddejo3d016zrrwwj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnyo6ddejo3d016zrrwwj.png" alt=" " width="722" height="280"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The example finds the sum of all number in the array. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;total (accumulator) starts as the first element - 30.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Iteration starts from the second element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Above the example is used only the value.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Output:&lt;br&gt;
79&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. reduceRight()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;reduce()&lt;/code&gt; method runs a function on each array element to produce a single value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;But it processes the array from right to left (descending index order). &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffh99lzknrvpww97jeyti.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffh99lzknrvpww97jeyti.png" alt=" " width="710" height="284"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;total starts as the last element - 25&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Iteration starts from the second-last element&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;reduce()&lt;/code&gt; is start from beginning &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;reduceRight()&lt;/code&gt; is start from end&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Output:&lt;br&gt;
79&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. every()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;every()&lt;/code&gt; method test whether all elements in an array pass a specific condition.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This method return the boolean value.It returns &lt;code&gt;true&lt;/code&gt; only if ALL elements pass the condition.If even one element fails - returns &lt;code&gt;false&lt;/code&gt; immediately&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw5mwzeq39d506z3es2vf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw5mwzeq39d506z3es2vf.png" alt=" " width="719" height="278"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the example check it all array values are larger than 35&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Output:&lt;br&gt;
false &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. some()&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;some()&lt;/code&gt; method is used to check if at least one element in an array passes a specific test.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It's return the boolean value.&lt;code&gt;true&lt;/code&gt; if it finds a match, and &lt;code&gt;false&lt;/code&gt; otherwise.  &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgw1m2v9rulkfumsomi38.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgw1m2v9rulkfumsomi38.png" alt=" " width="707" height="274"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This example checks if some array values are larger than 35&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Output:&lt;br&gt;
true&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9. Array.from()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;Array.from()&lt;/code&gt;  method is a static method in JavaScript used to create a new, shallow-copied Array instance from an iterable or array-like object.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Any object with a length property&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8886q6i7gu9mg3u0fnc1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8886q6i7gu9mg3u0fnc1.png" alt=" " width="567" height="127"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;This Array,from is takes the string.It splits each character  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;And it's Take the word MESSI, break it into letters, and store them in an array.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Output:&lt;br&gt;
[ 'M', 'E', 'S', 'S', 'I' ]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10.  keys()&lt;/strong&gt;-(TBD)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;keys()&lt;/code&gt;  method of an array returns a new Array Iterator object that contains the indexes (keys) for each element in the array,not the values. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Returns provides an Array Iterator rather than a list of values.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwkqb4jesll4gk1dpzek3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwkqb4jesll4gk1dpzek3.png" alt=" " width="742" height="148"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
Object [Array Iterator] {}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;12.with()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;with()&lt;/code&gt;method is used to update a single element in an array by returning a new array with the change applied.without changing the original array.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzk9oyt66xvyz08267np7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzk9oyt66xvyz08267np7.png" alt=" " width="520" height="153"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;*arr.with(1, 10) → replace the element at index 1.Then the Index 1 currently has 30&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It returns a new array with that value replaced&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;arr&lt;/code&gt; stays the same (immutable)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;newarr&lt;/code&gt; is the modified copy&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Output:&lt;br&gt;
[ 20, 30, 40 ]//unchanged &lt;br&gt;
[ 20, 10, 40 ]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;13. Spread (...)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;Spread (...)&lt;/code&gt; method is represented by three dots (...) and is used to expand or "spread" the elements of an iterable—like an array, string, or object—into individual items. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This method create a shallow copy.So dose not change the original array.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fschw1x0zzdipnqwb1x8n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fschw1x0zzdipnqwb1x8n.png" alt=" " width="590" height="152"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;...arr1&lt;/code&gt; - spreads elements: 20, 30, 40,&lt;code&gt;...arr2&lt;/code&gt; - spreads elements: 50, 60, 70&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;...arr3&lt;/code&gt; is  combined into a new array&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Output:&lt;br&gt;
[ 20, 30, 40, 50, 60, 70 ]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;14. Rest (...)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;Rest (...)&lt;/code&gt; method is generally refers to the rest parameter (or rest operator) syntax, which is written as three dots (...) followed by a variable name. It is used to collect multiple elements and "condense" them into a single array.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The rest operator (...) allows us to destruct an array and collect the leftovers.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpab1j65fmtcf9b6bj7uu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpab1j65fmtcf9b6bj7uu.png" alt=" " width="779" height="216"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A &lt;code&gt;first&lt;/code&gt; gets the first element - 20&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then &lt;code&gt;second&lt;/code&gt; gets the second element - 30&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;...others&lt;/code&gt; are collect the remaining elements into an array - [40,50,60,]&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Output:&lt;br&gt;
20&lt;br&gt;
30&lt;br&gt;
[ 40, 50, 60 ]&lt;/p&gt;

&lt;p&gt;REFERENCE : &lt;a href="https://www.w3schools.com/js/js_array_iteration.asp" rel="noopener noreferrer"&gt;https://www.w3schools.com/js/js_array_iteration.asp&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Discuss about the topics of 1.what is callback function in js 2.Javascript is single threaded or multithreaded ? 3. Array iteration methods in js</title>
      <dc:creator>mohandass</dc:creator>
      <pubDate>Tue, 14 Apr 2026 10:01:26 +0000</pubDate>
      <link>https://forem.com/mohandassmani/discuss-about-the-topics-of-1what-is-callback-function-in-js-2javascript-is-single-threaded-or-5cd3</link>
      <guid>https://forem.com/mohandassmani/discuss-about-the-topics-of-1what-is-callback-function-in-js-2javascript-is-single-threaded-or-5cd3</guid>
      <description>&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A callback function in javascript is a function passed as an argument into another function.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Which is then executed or (callback) inside that outer function to complete the specific task.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Later is typically when a specific event occurs or an asynchronous operation completes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;BASIC CALLBACK:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw2egauojm0399uwx8zsf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw2egauojm0399uwx8zsf.png" alt=" " width="777" height="476"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;OUTPUT:&lt;br&gt;
Hello, thomas &lt;br&gt;
Goodbye&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of Callback&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are two primary ways callback are used:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Asynchronous callback&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Synchronous callback&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;ASYNCHRONOUS &lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Asynchronous callback is executed immediately during the execution of the main function,blocking further code until finish.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:Array.Prototype.&lt;code&gt;forEach()&lt;/code&gt;,&lt;code&gt;map()&lt;/code&gt;,and &lt;code&gt;filter()&lt;/code&gt;-(TBD)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;SYNCHRONOUS &lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Synchronous callback is executed at a later time after an operation like fetching data or a time.Completes allowing the rest of the program to continue running in meantime.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Examples: &lt;code&gt;setTimeout()&lt;/code&gt;, &lt;code&gt;addEventListener()&lt;/code&gt;, and network requests (API calls)-(TBD)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Javascript is single threaded or Multithreaded&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Javacsript is a single-threaded meaning it executes one task at a time on a single main thread.While the language itself dose not support multi threads for execution it achieves concurrency doing many things at once through an event-driven,non-blocking architecture.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Array Iteration Methods in javascript&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A javascript in array iteration methods are built in tools that allow you to loop through array elements and perform operations on them.These methods typically take a callback function as a argument which is executed for each items in the array.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Array forEach&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array map()&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array flatMap()&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array filter()&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array reduce()&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array reduceRight()&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array every()&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array some()&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array from()&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array keys()&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array entries()&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array with()&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array Spread (...)&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Array Rest (...)&lt;/code&gt; - (TBD)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. forEach&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The forEach() method calls a function (a callback function) once for each array element.It's used for side effects, and returns undefined.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcj5rx5zwqkugt3uhjx36.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcj5rx5zwqkugt3uhjx36.png" alt=" " width="800" height="273"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that the function takes 3 arguments &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The item value&lt;/li&gt;
&lt;li&gt;The item index&lt;/li&gt;
&lt;li&gt;The array itself &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Above the example used the value and index parameters only.&lt;/p&gt;

&lt;p&gt;OUTPUT:&lt;br&gt;
50  0&lt;br&gt;
30  1&lt;br&gt;
25  2&lt;br&gt;
10  3&lt;br&gt;
60  4&lt;/p&gt;

</description>
    </item>
    <item>
      <title>WHAT IS FTP,TCP</title>
      <dc:creator>mohandass</dc:creator>
      <pubDate>Sat, 11 Apr 2026 18:09:27 +0000</pubDate>
      <link>https://forem.com/mohandassmani/what-is-ftptcp-567i</link>
      <guid>https://forem.com/mohandassmani/what-is-ftptcp-567i</guid>
      <description>&lt;p&gt;&lt;strong&gt;1. File Transfer Protocol(FTP)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;File transfer protocol(FTP) is an application layer protocol that Used to file transfer between client and a server over a TCP,IP Network.It's provide a standardized method for file exchange across Different system.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Support text,image,binary,and program files.&lt;/li&gt;
&lt;li&gt;Enable uploading,downloading,and remote file management.&lt;/li&gt;
&lt;li&gt;Used to TCP for ensure reliable communication.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Working and Uses of FTP&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;FTP follows a client-server model and uses two connections&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Control connection (port 21) for commends. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Data connection(port 20)for file transfer. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;User connect to the server use login credentials. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;User navigate directories used commends ls and cd.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using for transferring files uses get and put.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;supports both active and passive mods for communication.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
         control channel 
client -------------------&amp;gt; sever 
       &amp;lt;------------------                     
           Data channel 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Types of Connection in FTP&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;FTP use two separate TCP connection to handle communication one dedicating to control information and another dedicating to actual data transfer &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Control connection &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;data connection &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;FTP Data Types&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;FTP data types define how file contents are represented and transmitted between the client and server during file transfer.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;ASCII: This data type is used for transferring text files with character encoding based on the ASCII standard.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;EBCDIC: This data type is used for transferring text files encoded in IBM’s Extended Binary Coded Decimal Interchange Code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Image (Binary): This data type transfers files as a continuous stream of bytes without any modification.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Local: This data type is used for transferring files that contain data stored in logical bytes of a specified bit length.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;FTP common commends&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;get filename - download a single file in the server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;mget filename - download a multiple files form the server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ls - used for list of the files in the current server directory.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Types of FTP&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Anonymous FTP&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Password-Protected FTP&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;FTPS (FTP Secure)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SFTP (SSH File Transfer Protocol)&lt;br&gt;
(TBD)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Transmission control protocol(TCP)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Transmission control protocol is the protocol that allow the device communicate reliable a network.It is ensure that data reaches the destination correctly and a right order.Even the part of the network slow and unreliable.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It works at the Transport Layer (Layer 4) of the OSI model and is an essential part of the TCP/IP protocol suite used for Internet communication.&lt;/li&gt;
&lt;li&gt;TCP establishes a logical connection between the sender and receiver before data transmission begins.&lt;/li&gt;
&lt;li&gt;It ensures that data is delivered accurately and in the same order in which it was sent using acknowledgements and sequence numbers.&lt;/li&gt;
&lt;li&gt;TCP detects errors using checksums and retransmits lost or corrupted packets to maintain data integrity.&lt;/li&gt;
&lt;li&gt;It controls the data transmission rate to avoid overwhelming the receiver and adapts to network congestion for efficient communication. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Connection Establishment (Three-Way Handshake)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;TCP is connection-orientated, meaning a connection must be established before any data is sent. This is done using a three-way handshake&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TCP Handshake process&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;           FIN-ACK
       --------------&amp;gt;
             ACK
       &amp;lt;------------- 
           ACK-FIN
 Client&amp;lt;--------------Server  
             ACK
      ---------------&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 1: FIN (Client → Server): The client sends a FIN segment to initiate closure, entering the FIN-WAIT-1 state.&lt;/p&gt;

&lt;p&gt;Step 2: ACK (Server → Client): The server sends an ACK to acknowledge the FIN. The server enters CLOSE-WAIT (can still send data), and the client enters FIN-WAIT-2.&lt;/p&gt;

&lt;p&gt;Step 3: FIN (Server → Client): Once the server finishes sending remaining data, it sends its own FIN segment to the client.&lt;/p&gt;

&lt;p&gt;Step 4: ACK (Client → Server): The client sends an ACK to acknowledge the server's FIN, entering the TIME-WAIT state. After a set period, the connection is fully closed. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;WORKING&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Segmenting&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Routing via IP&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reassembly at Receiver&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Acknowledgments (ACKs)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Retransmission&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Flow &amp;amp; Error Control&lt;br&gt;
(TBD)&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;REFERENCE:&lt;a href="https://www.geeksforgeeks.org/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>computerscience</category>
      <category>networking</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Discuss about the topics of 1.what is javascript 2.Comparison of data types in js 3.Different Between Primitive and Non-primitive</title>
      <dc:creator>mohandass</dc:creator>
      <pubDate>Thu, 09 Apr 2026 19:14:15 +0000</pubDate>
      <link>https://forem.com/mohandassmani/discuss-about-the-topics-of-1what-is-javascript-2comparison-of-data-types-in-js-3different-2h59</link>
      <guid>https://forem.com/mohandassmani/discuss-about-the-topics-of-1what-is-javascript-2comparison-of-data-types-in-js-3different-2h59</guid>
      <description>&lt;p&gt;&lt;strong&gt;what is javascript&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Javascript is the high level,interpreted language that sever is the One of the core technologies of the world wide web.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Used to create Interactive and dynamic content for websites. While HTML provides the Structure of a page and CSS handled the style.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Javascript can ,calculate,mainpulat,and validate data.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Javascript is an object-oriented programing(OOP)language.But it is unique because it is prototype based rather than class based like (java,c++).&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;JavaScript is both a scripting language and a programming language.While it originated as a lightweight scripting tool for web browsers, it has evolved into a full-fledged, high-level programming language used for complex applications across many platforms. &lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Javascript is provides The behavior what make things on the page move,react or update to Your click. &lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Comparison of data types in javascript&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In javascript data types are broadly categorized into "primitive" and "non-primitive"(reference) types.The fundamental difference lies in how they are stored in memory and how they behave during assignment or modifying.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Primitive Data Types&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Primitive data types are the built-in data types provide by a javascript.They represent single values and are not mutable. JavaScript supports the following primitive data types&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;string&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;number&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;boolean&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;null&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;undefined&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;bigInt&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;symbol&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;String&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;string&lt;/code&gt; data type is used to represent a sequence of characters that are surrounding by a single or double quotes &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:"hello",'welcome'&lt;/p&gt;

&lt;p&gt;2.&lt;strong&gt;Number&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;code&gt;number&lt;/code&gt; data type is used to integers and floating point numbers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:(10,5,25)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Boolean&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;it's logical values either &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;null&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;The null is intentional  absence any value&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;undefined&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;The undefined is variables declared but assigned a value&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Bigint&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;It's used for very larger integer and number type
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:(9007199254740991n)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;symbol&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;It's used for unique identifiers in object properties &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Non-primitive data types&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The non-primitive data types are complex data structure that can store collection of value or more complicate entities.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;object&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Array&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Function&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Object&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The object is collect a key value pairs used to store data&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It's used to curly bracket {}&lt;br&gt;
example:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fynuyg72tew7tzcy992up.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fynuyg72tew7tzcy992up.png" alt=" " width="800" height="101"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Array&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The array is used to multiple values in single container &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It's use with square bracket []&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F500keeocuyceutn2tsie.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F500keeocuyceutn2tsie.png" alt=" " width="800" height="88"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Function&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The function is used to reusable block of code designed  to perform a task.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F30l6eo84gaoi27j7hulv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F30l6eo84gaoi27j7hulv.png" alt=" " width="800" height="188"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Different Between primitive and Non-primitive Data Types&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Primitive data type:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;*&lt;code&gt;immutable&lt;/code&gt; their values can not be changed once created &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It's mean the  immutable is reassign the values dose not replace a memory in older one.Then create the new memory to stored the values
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let i = 10;
i = 20;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Storage&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Stored the values directly in the stack&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Every values stored the stack in line by line &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;FILO - first in last out &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Comparison&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;compared by a actual value &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbh6am9bp5z3iedhd4fix.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbh6am9bp5z3iedhd4fix.png" alt=" " width="800" height="107"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Methods&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Do not have any builtin  methods but use the wrappers &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Non-primitive Data Types&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;mutable&lt;/code&gt; The content can be changed or modified after creation &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;Storage&lt;/code&gt;: Stored by the heap &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dose not maintaining any order stored by the heap&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Comparison&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Compared by memory reference or address &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgdh5mo92ckeoj5cb6hkz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgdh5mo92ckeoj5cb6hkz.png" alt=" " width="800" height="105"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;REFERENCE :&lt;br&gt;
&lt;a href="https://www.w3schools.com/js/js_datatypes.asp" rel="noopener noreferrer"&gt;https://www.w3schools.com/js/js_datatypes.asp&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.geeksforgeeks.org/javascript/primitive-and-non-primitive-data-types-in-javascript/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/javascript/primitive-and-non-primitive-data-types-in-javascript/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Array basic methods in j.s</title>
      <dc:creator>mohandass</dc:creator>
      <pubDate>Wed, 08 Apr 2026 21:42:26 +0000</pubDate>
      <link>https://forem.com/mohandassmani/array-basic-methods-in-js-3nje</link>
      <guid>https://forem.com/mohandassmani/array-basic-methods-in-js-3nje</guid>
      <description>&lt;ul&gt;
&lt;li&gt;In javascript,array methods are built in the functions that help you add,remove,or manipulate elements in the array.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;1. Array length&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;length&lt;/code&gt; is property that tells you how many elements are in an array. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;EXAMPLE:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9kkmulrikpixxtwt4vi3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9kkmulrikpixxtwt4vi3.png" alt=" " width="514" height="82"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inside the array have a 4 elements.So the size of length is 4.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;OUTPUT:&lt;br&gt;
4&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Array toString()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;toString()&lt;/code&gt; array method that coverets an array an array into a comma separated string. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;EXAMPLE:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4c8fj9nu1f0ai95lywa4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4c8fj9nu1f0ai95lywa4.png" alt=" " width="507" height="76"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The toString method is join all elements into a string separate&lt;br&gt;
a comma.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;this method dose not change the original array. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;OUTPUT:&lt;br&gt;
BMW,TATA,BENZ,VOLVO&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Array at()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;at()&lt;/code&gt; method is used to access an elements in  array using its  indexed. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;EXAMPLE:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhm7luzr8iu9xwqfx8u5h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhm7luzr8iu9xwqfx8u5h.png" alt=" " width="471" height="84"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The carbrand.at(2) returns an indexed element 2 is the "BENZ"&lt;/li&gt;
&lt;li&gt;Dose not modify the array.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;OUTPUT:&lt;br&gt;
BENZ&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Array join()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;join()&lt;/code&gt; method is used to covert an array into a string it's join all elements with a specified separator. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It's behaves just like &lt;code&gt;toString()&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;EXAMPLE:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyyhl20pshms1fem95ul0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyyhl20pshms1fem95ul0.png" alt=" " width="464" height="91"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It this join() array method we gives the ( - ).so it's create a array into a string joins with inbetween (-) all elements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The original array stays unchanged.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;OUTPUT:&lt;br&gt;
BMW-TATA-BENZ-VOLVO&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Array pop()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;pop()&lt;/code&gt; is used to remove the last elements from a array and it's return that elements.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;EXAMPLE:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqla1z0dc3yf1g6jpok9s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqla1z0dc3yf1g6jpok9s.png" alt=" " width="480" height="85"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This pop() method is remove the array last elements "VOLVO"&lt;/li&gt;
&lt;li&gt;it's modified the original array. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;OUTPUT:&lt;br&gt;
[ 'BMW', 'TATA', 'BENZ' ]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Array push()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;push()&lt;/code&gt; method is used to add one or more elements in end of the array.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;EXAMPLE:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F125dsjuqprk3r8jtomjv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F125dsjuqprk3r8jtomjv.png" alt=" " width="480" height="83"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;This push() method add element "AUDI" to the end an array. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is also modified the original array and new length of the array.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;OUTPUT:&lt;br&gt;
[ 'BMW', 'TATA', 'BENZ', 'VOLVO', 'AUDI' ]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Array shift()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;shift()&lt;/code&gt; array method is used to remove the first elements from the array and return that all other elements to string index.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;EXAMPLE:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5d5hkc88hhvz3ir1kgpj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5d5hkc88hhvz3ir1kgpj.png" alt=" " width="498" height="88"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;This shift() method is remove the first element "BMW" and then remaining  element are shift into the place of removed element. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This method is changed the original array. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;OUTPUT:&lt;br&gt;
[ 'TATA', 'BENZ', 'VOLVO' ]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. Array unshift()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;Array unshift()&lt;/code&gt; is used to add one or more elements to the starting from the array.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;EXAMPLE:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvxlhx6vlff53tz6uwplk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvxlhx6vlff53tz6uwplk.png" alt=" " width="505" height="106"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;This unshift() method is add "MG" elements beginning the array.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It's changed the original array and return the new length of the array.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;OUTPUT:&lt;br&gt;
[ 'MG', 'BMW', 'TATA', 'BENZ', 'VOLVO' ]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9. Array.isArray()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;Array.isArray()&lt;/code&gt; method is used to check whatever a value is an array it's return the &lt;code&gt;true&lt;/code&gt; and &lt;code&gt;false&lt;/code&gt; otherwish it's not a array.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;EXAMPLE:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2rpluer4k7vp2zmktoz2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2rpluer4k7vp2zmktoz2.png" alt=" " width="501" height="99"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the carbrand is array.so the return is "true".&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;OUTPUT:&lt;br&gt;
true&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10. Array delete()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;Array delete()&lt;/code&gt; method is used leaves undefined holes in the array.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you the pop() or shift()  method instead of delete.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;EXAMPLE:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2nz9oqtbsff1xr127mps.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2nz9oqtbsff1xr127mps.png" alt=" " width="497" height="107"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Use  &lt;code&gt;delete&lt;/code&gt; method to remove the mentioned value.But another elements are not shift the array.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The array length is not changed. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;OUTPUT:&lt;br&gt;
[ 'BMW', &amp;lt;1 empty item&amp;gt;, 'BENZ', 'VOLVO' ]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;11. Array concat()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;concat()&lt;/code&gt; is used to merge two or more array into the new array without changing the original array &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;EXAMPLE:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ef4nmuq60uub1bct0lz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ef4nmuq60uub1bct0lz.png" alt=" " width="488" height="147"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The concat method merge the carbrand2 array and carbrand1 array in a combine with order for all values &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The original array dose not changed &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;OUTPUT:&lt;/p&gt;

&lt;p&gt;[ "BMW", "TATA", "BENZ", "VOLVO", "AUDI", "HONDA", "TOYOTA", "KIA" ]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;12. copyWithin()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;copyWithin()&lt;/code&gt; method used to copy the part of  array elements to the another location in the same array &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;EXAMPLE:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feou642y8j3ix0bvb5ast.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feou642y8j3ix0bvb5ast.png" alt=" " width="456" height="100"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;OUTPUT:&lt;br&gt;
[ 'BMW', 'TATA', 'BENZ', 'TATA' ]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;13. Array flat()&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;code&gt;Array flat()&lt;/code&gt; method is used create a new array where sub-array elements are marge with main array &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;EXAMPLE:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe621oxa5t61wf7aaclih.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe621oxa5t61wf7aaclih.png" alt=" " width="482" height="105"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;OUTPUT:&lt;/p&gt;

&lt;p&gt;[ 'BMW', 'TATA', 'BENZ', 'VOLVO' ]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;14. Array slice()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;slice()&lt;/code&gt; method is slice out a piece of array into a new array &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;EXAMPLE:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd0xnmofhr3uj52todmg4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd0xnmofhr3uj52todmg4.png" alt=" " width="439" height="100"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Return a new array&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It's not changed the original array &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;OUTPUT:&lt;br&gt;
[ 'BMW', 'TATA' ]&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;15. Array splice()&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;splice()&lt;/code&gt; method is used to add,remove,or replace elements in an array &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;EXAMPLES:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;removing elements&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs3qwhswc4wn8c711am0p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs3qwhswc4wn8c711am0p.png" alt=" " width="800" height="84"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Adding elements&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvzfdddvnif5t3tjy11fs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvzfdddvnif5t3tjy11fs.png" alt=" " width="800" height="93"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Replace elements&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy8nyi28o6od3jut1fs4o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy8nyi28o6od3jut1fs4o.png" alt=" " width="800" height="106"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;16. Array toSpliced()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;EXAMPLE:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb2tavalfceelyqxgeqb0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb2tavalfceelyqxgeqb0.png" alt=" " width="800" height="106"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Constructor function and return statement in j.s</title>
      <dc:creator>mohandass</dc:creator>
      <pubDate>Tue, 07 Apr 2026 19:05:36 +0000</pubDate>
      <link>https://forem.com/mohandassmani/constructor-function-and-return-statement-in-js-4j9h</link>
      <guid>https://forem.com/mohandassmani/constructor-function-and-return-statement-in-js-4j9h</guid>
      <description>&lt;p&gt;&lt;strong&gt;CONSTRUCTOR FUNCTION&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A constructor function in JavaScript is a special function used as &lt;br&gt;
blueprint to create and initialize multiple objects of the same type.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It defines the structure (properties) and behavior (methods) that every instance created from it will possess. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To create a object type we can use the constructor function.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is considered to the good practice to name constructor function with an using a upper-case letter in the first letter &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create the constructor you must be called with the &lt;code&gt;new&lt;/code&gt; operator &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;const car1={&lt;br&gt;
brand: "ford",&lt;br&gt;
price: 6,00,000,&lt;br&gt;
color: "blue",&lt;/p&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;const car2{&lt;br&gt;
brand: "tata",&lt;br&gt;
price: 6,70,000,&lt;br&gt;
color: "red",&lt;br&gt;
}&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It is the normal  object creating method for car details &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This type of method to using for two or three car details.If you can write the all ford car details so this method is too difficult &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;we can use the constructor function lets you reuse code to create many objects to easily with single line code &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;EXAMPLE:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs7ufssstjote9an2mior.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs7ufssstjote9an2mior.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;EXPLANATION:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Create a function with write the parameters (brand,price,color)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then use &lt;code&gt;this&lt;/code&gt; to assign properties&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Write a single line code for&lt;br&gt;
const car1 = new Car ("ford",600000,"blue")&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;const car2 = new Car ("tata",670000,"red")&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Use the &lt;code&gt;new&lt;/code&gt; keyword,when use the "new" keyword for reason is you first create a function in "car" that is the new car &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then Print the full object like &lt;br&gt;
console.log(car1)//Car{ brand: 'ford', price: 600000, color: 'blue' }&lt;br&gt;
console.log(car2)//Car { brand: 'tata', price: 670000, color: 'red' }&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you want Print individual properties&lt;br&gt;
console.log(car1.brand); // ford&lt;br&gt;
console.log(car1.price); // 600000&lt;br&gt;
console.log(car1.color); // blue&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;&lt;strong&gt;RETURN STATEMENT&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The return statement in javascript is used inside a function to do Two main things.It stop the function from running and sends a values Back to whoever it called. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the caller don't return a value.the value not used for any variable &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;EXAMPLE:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
 &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
 &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;br&gt;
25&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Creating a function named - add&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It's take the two parameters a and b &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;return a + b; add the two values&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then sends back the result &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you call the function with values 5 and 20// a=5 , b=20 \it calculate 5 + 20=25&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The return sends back "5"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The value is stored by variable "result"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then print the result output is "25"&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Objects in javascript</title>
      <dc:creator>mohandass</dc:creator>
      <pubDate>Mon, 06 Apr 2026 17:28:38 +0000</pubDate>
      <link>https://forem.com/mohandassmani/objects-in-javascript-gf7</link>
      <guid>https://forem.com/mohandassmani/objects-in-javascript-gf7</guid>
      <description>&lt;ul&gt;
&lt;li&gt;&lt;p&gt;In javascript an object is a standalone data structure used to Store collection of related data and more complex entities.Unlink Primitive data types like string or numbers.Store a single Value,object act as containers for multiple values organized as the Key-value pairs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;keys also called as properties (string or symbols)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Object are variables that store both values and function&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Values can be anything : numbers,strings,arrays,function,or even Other objects&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Object are one of the most important concept in javascript &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Object is the mutable and dynamic properties it can be add,modify and delete at any time &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Object contains methods and properties  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Object are using with curly bracket {}&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;SYNTAX&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;const object name={&lt;br&gt;
properties (key-pairs)&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CRUD operation of object&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;C-(create)&lt;br&gt;
R-(read)&lt;br&gt;
U-(update)&lt;br&gt;
D-(delete)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;CREATE - Adding data&lt;/strong&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can create a new object or new properties &lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7p3qdveqze1ahhfvjy0h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7p3qdveqze1ahhfvjy0h.png" alt=" " width="278" height="111"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;name,age - are keys &lt;/li&gt;
&lt;li&gt;mohan,25 - are their values &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Output:&lt;br&gt;
{ name: 'mohan', age: 25 }&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;READ - Access data&lt;/strong&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can read a values using dot notation in the bracket notation&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpwy03dgrvzjhfhpwrnq0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpwy03dgrvzjhfhpwrnq0.png" alt=" " width="481" height="191"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
mohan&lt;br&gt;
25&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;UPDATE - Modify data&lt;/strong&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can change the existing values&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fatwlkra9igq1sh2ctjtg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fatwlkra9igq1sh2ctjtg.png" alt=" " width="362" height="228"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
mohan&lt;br&gt;
27&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Delete - Remove data&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can remove properties using the (delete) keyword&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F20eepld13aerfb8crdom.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F20eepld13aerfb8crdom.png" alt=" " width="466" height="234"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
{ age: 27 }&lt;/p&gt;

&lt;p&gt;REFERENCE:&lt;a href="https://www.w3schools.com/js/js_objects.asp" rel="noopener noreferrer"&gt;https://www.w3schools.com/js/js_objects.asp&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Function in j.s</title>
      <dc:creator>mohandass</dc:creator>
      <pubDate>Sun, 05 Apr 2026 05:10:23 +0000</pubDate>
      <link>https://forem.com/mohandassmani/function-in-js-3389</link>
      <guid>https://forem.com/mohandassmani/function-in-js-3389</guid>
      <description>&lt;p&gt;Functions in javascript is the reusable blocks of code designed to Perform specific task.Instead of writing the same code again and Again you can put it inside a function and call it whenever needed.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SIMPLE IDEA &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A function is like a machine,You can give a inputs it's called (parameters),it's processes and gives to back a output(called a return value).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SYNTAX&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;function ogadd(boys, girls);&lt;br&gt;
  return boys + girls;&lt;br&gt;
}&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Function is the keyword referring that we are writing a function&lt;/li&gt;
&lt;li&gt;ogadd is the name given to the function it's used to call the function &lt;/li&gt;
&lt;li&gt;boys and girla are the parameters inputs of the function it's  like a Variable &lt;/li&gt;
&lt;li&gt;&lt;p&gt;return is the keyword if can used to the return the result once the Function is called &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;EXECUTION &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;let result = ogadd(25, 20);&lt;br&gt;
console.log(result);&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Once if you can calling the function is 25 and 20 are  the arguments It's take the place of parameters boys and girls&lt;/li&gt;
&lt;li&gt;It's runs the function addition operation returns the value 45 is Stored in the variable result&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We have a returned the value it will stored in the variable result &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;SIMPLE UNDERSTANDING &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Start with function is defined - ogadd&lt;/li&gt;
&lt;li&gt;Next function is called - ogadd(25, 20)&lt;/li&gt;
&lt;li&gt;Then assigned the value for boys and girls - boys = 25, girls = 20&lt;/li&gt;
&lt;li&gt;Calculation - 25 + 20 = 45&lt;/li&gt;
&lt;li&gt;The function returns 45&lt;/li&gt;
&lt;li&gt;The return value 45 is stored in result&lt;/li&gt;
&lt;li&gt;finely printing  the result to the console.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Reference:&lt;a href="https://www.w3schools.com/js/js_functions.asp" rel="noopener noreferrer"&gt;https://www.w3schools.com/js/js_functions.asp&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Array simple explanation with examples in j.s</title>
      <dc:creator>mohandass</dc:creator>
      <pubDate>Thu, 02 Apr 2026 16:01:48 +0000</pubDate>
      <link>https://forem.com/mohandassmani/array-simple-explanation-with-examples-in-js-37kl</link>
      <guid>https://forem.com/mohandassmani/array-simple-explanation-with-examples-in-js-37kl</guid>
      <description>&lt;ul&gt;
&lt;li&gt;An array in javascript is a special type of variable  that can store Multiple value in single place.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instant of creating  many variables &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjaw6fol0fldjalgw22wf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjaw6fol0fldjalgw22wf.png" alt=" " width="259" height="104"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can use the array&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftpav90krkr7050q9scdp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftpav90krkr7050q9scdp.png" alt=" " width="296" height="33"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ordered - Items have positions "if called indexes, starting from 0"&lt;/li&gt;
&lt;li&gt;You Can store any type - numbers, strings, objects, and other arrays&lt;/li&gt;
&lt;li&gt;Dynamic - You can add/remove elements anytime&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you can using (const)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You cannot reassign the array &lt;/li&gt;
&lt;li&gt;But you can modify the content inside the array&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;const marks = [70,50,30,60,80]&lt;br&gt;
               0  1  2  3  4&lt;br&gt;
Using a bracket starting mark value is "0",second mark value is "1",third mark value is "2",fourth mark value is "3" and fifth mark value is "4"&lt;/p&gt;

&lt;p&gt;HOW TO FIND THE COUNT OF FAIL ?&lt;/p&gt;

&lt;p&gt;If using a array and while loop method to find the fail count&lt;/p&gt;

&lt;p&gt;const marks = [70,50,30,60,80]&lt;br&gt;
let fail = 0;&lt;br&gt;
let i = 0;&lt;br&gt;
while (i &amp;lt; 5){&lt;br&gt;
    if (marks[i] &amp;lt; 35){&lt;br&gt;
       fail++; &lt;br&gt;
    }&lt;br&gt;
    i++;&lt;br&gt;
}&lt;br&gt;
console.log("fail count" ,fail)&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
 fail count 1&lt;/p&gt;

&lt;p&gt;STEPS :&lt;br&gt;
step 1:Declare a mark in array using (const marks) in square brackets "[]" to order the values &lt;/p&gt;

&lt;p&gt;step 2: we want how many fail count in the marks.we don't know how many  fail count.So declare the name fail "let fail = 0" &lt;/p&gt;

&lt;p&gt;step 3: Then declare the first elements of array is index. so start form 0 "let i = 0" &lt;/p&gt;

&lt;p&gt;step 4: Next use the while loop (i &amp;lt; 5) because the array have a five  Elements the index starting from 0 to 4 &lt;/p&gt;

&lt;p&gt;step 5: and then declare the if condition if(marks[i]&amp;lt;35)&lt;/p&gt;

&lt;p&gt;step 6: if the condition is true increase the fail count "fail++"&lt;/p&gt;

&lt;p&gt;step 7:  increase the i inside the looping bracket &lt;br&gt;
Important point : increase the i into the if condition that is "infinity loop" &lt;/p&gt;

&lt;p&gt;step 8: And then print the fail count "console.log("fail count", fail)"   &lt;/p&gt;

&lt;p&gt;How  working process in this program &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;we want the fail count above the mark.So declare the fail count is 0&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;2.Next declare the i = 0&lt;/p&gt;

&lt;p&gt;3.if check the while loop condition &lt;br&gt;
i=0&lt;br&gt;
while (0 &amp;lt; 5)-condition is true &lt;/p&gt;

&lt;p&gt;i=1&lt;br&gt;
while(1 &amp;lt; 5)-condition is true &lt;/p&gt;

&lt;p&gt;i=2&lt;br&gt;
while(2 &amp;lt; 5)-condition is true&lt;/p&gt;

&lt;p&gt;i=3&lt;br&gt;
while(3 &amp;lt; 5)-condition is true&lt;/p&gt;

&lt;p&gt;i=4&lt;br&gt;
while(4 &amp;lt; 5)-condition is true&lt;/p&gt;

&lt;p&gt;i=5&lt;br&gt;
while(5 &amp;lt; 5)-condition is false so loop stop &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Next check the if condition &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;index 0=70&lt;br&gt;
if(marks[70]&amp;lt;35)-condition is false&lt;/p&gt;

&lt;p&gt;index 1=50&lt;br&gt;
if(marks[50]&amp;lt;35)-condition is false&lt;/p&gt;

&lt;p&gt;index 2=30&lt;br&gt;
if(marks[30]&amp;lt;35)-condition is true&lt;/p&gt;

&lt;p&gt;index 3=60&lt;br&gt;
if(marks[60]&amp;lt;35)-condition is false&lt;/p&gt;

&lt;p&gt;index 4=80&lt;br&gt;
if(marks[80]&amp;lt;35)-condition is false&lt;/p&gt;

&lt;p&gt;4.If the condition is true fail count is increase.the index condition  0,1,3,4 it's all false.If the fail count not increase &lt;br&gt;
The index 3 only true so the fail count is increase fail count is 1&lt;/p&gt;

&lt;p&gt;5.Then finally when the loop is stop.Then  print the fail count  &lt;/p&gt;

&lt;p&gt;OUTPUT: fail count 1&lt;/p&gt;

&lt;p&gt;How to find count of fail and pass &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjl58vz7ybxilvj3x4200.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjl58vz7ybxilvj3x4200.png" alt=" " width="800" height="231"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And find a total marks &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk1x8y0cz09x4zl2trfuu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk1x8y0cz09x4zl2trfuu.png" alt=" " width="800" height="128"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>html</category>
    </item>
    <item>
      <title>Flowchart for while looping</title>
      <dc:creator>mohandass</dc:creator>
      <pubDate>Fri, 27 Mar 2026 09:08:06 +0000</pubDate>
      <link>https://forem.com/mohandassmani/flowchart-for-while-looping-2l21</link>
      <guid>https://forem.com/mohandassmani/flowchart-for-while-looping-2l21</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw8n6kglwv41ve0d71yz8.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw8n6kglwv41ve0d71yz8.jpg" alt=" " width="800" height="1043"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frub41pluahypsc32yprl.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frub41pluahypsc32yprl.jpg" alt=" " width="800" height="1086"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzeaznzraktva5w1j5gpt.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzeaznzraktva5w1j5gpt.jpg" alt=" " width="800" height="1161"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa8xn6qkjqx1xzipl00me.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa8xn6qkjqx1xzipl00me.jpg" alt=" " width="800" height="1227"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>gitlab</category>
      <category>javascript</category>
      <category>devto</category>
    </item>
  </channel>
</rss>
