<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Neetu J</title>
    <description>The latest articles on DEV Community by Neetu J (@neetu_j_29a5c6ffbec1df1c2).</description>
    <link>https://dev.to/neetu_j_29a5c6ffbec1df1c2</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%2F2158322%2Fde3eed97-f03f-4349-8f90-e5cdbe775896.png</url>
      <title>DEV Community: Neetu J</title>
      <link>https://dev.to/neetu_j_29a5c6ffbec1df1c2</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/neetu_j_29a5c6ffbec1df1c2"/>
    <language>en</language>
    <item>
      <title>Javascript Interview Coding Questions</title>
      <dc:creator>Neetu J</dc:creator>
      <pubDate>Mon, 07 Oct 2024 14:52:03 +0000</pubDate>
      <link>https://dev.to/neetu_j_29a5c6ffbec1df1c2/javascript-interview-coding-questions-119h</link>
      <guid>https://dev.to/neetu_j_29a5c6ffbec1df1c2/javascript-interview-coding-questions-119h</guid>
      <description>&lt;p&gt;&lt;strong&gt;1. Write the code for the second largest element in an Array.&lt;/strong&gt;&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const arr=[2,3,4,6,78,0,1,0,2,3,455,8,9];

   function secondLargest(arr){
      const sortedArray=[...new Set(arr)].sort((a,b)=&amp;gt;b-a);

      return sortedArray.length&amp;gt;=2 ? sortedArray[1] : null;
   }

  console.log("Second Largest Element:",secondLargest(arr));

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

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Second Largest Element: 78
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;2. Write the code to Sort the array without using the built-in &lt;br&gt;
      function.&lt;/strong&gt;&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const arr=[2,3,4,6,78,0,1,0,2,3,455,8,9];

   function sortArray(arr){
      let temp=0;

     for(let i=0;i&amp;lt;arr.length;i++){
         for(let j=arr.length-1;j&amp;gt;i;j--){
             if(arr[i]&amp;gt;arr[j]){
                temp=arr[i];
                arr[i]=arr[j];
                arr[j]=temp;
               }
          }
      }
      return arr;
   }
   console.log("Sorted Array:",sortArray(arr));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Sorted Array: [
    0, 0, 1, 2, 2,  3,
    3, 4, 6, 8, 9, 78,
    455
   ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Find out the unique element in an array without using 'Set'.&lt;/strong&gt;&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const arr=[2,3,4,6,78,0,1,0,2,3,455,8,9];

   function uniqueArray(arr){
      let tempArray=[];
      for(let i=0;i&amp;lt;arr.length;i++){
          if(tempArray.indexOf(arr[i])===-1){
            tempArray.push(arr[i]);
          }
       }
       return tempArray;
   }
   console.log("Unique Array of Element:",uniqueArray(arr));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Unique Array of Element: [
     2, 3,   4, 6, 78,
     0, 1, 455, 8,  9
     ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Write the code for reverse the array without using built-in &lt;br&gt;
     function.&lt;/strong&gt;&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const arr=[2,3,4,6,78,0,1,0,2,3,455,8,9];

      function reverseArray(arr){
         let tempArray=[];
         for(let i=arr.length-1;i&amp;gt;0;i--){
            tempArray.push(arr[i]);
         }
       return tempArray;
      }
      console.log("Reverse Array of Elements:",reverseArray(arr));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; Reverse Array of Elements: [
     9, 8, 455,  3, 2,
     0, 1,   0, 78, 6,
     4, 3
     ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;I hope this is useful to you. Have a great day!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>javascriptcoding</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
