<?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: Tahsin</title>
    <description>The latest articles on DEV Community by Tahsin (@thsn).</description>
    <link>https://dev.to/thsn</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%2F176908%2Fb8fedd33-eda8-4bb5-8b0a-cc38a18044b8.png</url>
      <title>DEV Community: Tahsin</title>
      <link>https://dev.to/thsn</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thsn"/>
    <language>en</language>
    <item>
      <title>When would be the ideal time to quit your unhappy job to seek new one?</title>
      <dc:creator>Tahsin</dc:creator>
      <pubDate>Thu, 25 Jun 2020 17:00:51 +0000</pubDate>
      <link>https://dev.to/thsn/when-would-be-the-ideal-time-to-quit-your-unhappy-job-to-seek-new-one-59bh</link>
      <guid>https://dev.to/thsn/when-would-be-the-ideal-time-to-quit-your-unhappy-job-to-seek-new-one-59bh</guid>
      <description>&lt;p&gt;I have been working for this job for seven months as a React developer which is my first job as a full-time frontend developer, before that I was working as a research assistant for almost 4 years. There are some managerial problems, work culture is a bit toxic and it is almost normal to organize a meeting on weekends(which is weirdly kind of perceived as normal in my country unfortunately.) &lt;br&gt;
I couldn’t stand with these conditions and I don’t think that I am not expanding my knowledge. However, I am always worried about that If I quit this right now, it will look bad on my CV and people might think that I am a kind of person who gives up easily and not reliable employee.&lt;/p&gt;

&lt;p&gt;What do you think? What would you do If you are in this situation as me?&lt;/p&gt;

</description>
      <category>career</category>
      <category>job</category>
      <category>discuss</category>
      <category>advice</category>
    </item>
    <item>
      <title>A question during my interview for a Front End Developer Position and my solution</title>
      <dc:creator>Tahsin</dc:creator>
      <pubDate>Sun, 12 Apr 2020 16:07:35 +0000</pubDate>
      <link>https://dev.to/thsn/a-question-during-my-interview-for-a-front-end-developer-position-and-my-solution-9ib</link>
      <guid>https://dev.to/thsn/a-question-during-my-interview-for-a-front-end-developer-position-and-my-solution-9ib</guid>
      <description>&lt;p&gt;Hello dear friends!&lt;/p&gt;

&lt;p&gt;So! Recently, I have been looking for new job opportunities and applying through LinkedIn, and then a company reached me and provide a test on Hackerrank which consists of 4 different questions. 2 of them are related HTML/CSS and dom manipulation, and the other 2 are about algorithmic thinking with programming language of your choice.(It would be obvious advantage to choose Javascript, I guess.( duh? ))&lt;/p&gt;

&lt;p&gt;Enough with chit-chat and gibberish talking, I am now going to trying to demonstrate and explain a bit my simplistic naive solution.&lt;/p&gt;

&lt;p&gt;Essentially, the question asks to sort an array based on both its values and number of occurrences of the elements.&lt;/p&gt;

&lt;p&gt;For example;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;//If the array is like this:&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&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;6&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;4&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="c1"&gt;//You need to return something like this:&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="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&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;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Firstly, I was thinking that I would be creating an object to hold the numbers as keys and their occurrences as values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;//To hold the frequency info for each element within items&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;frequency&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;

 &lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;forEach&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="o"&gt;=&amp;gt;&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;value&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;frequency&lt;/span&gt; &lt;span class="p"&gt;){&lt;/span&gt;
            &lt;span class="c1"&gt;//Once you run into the number again, &lt;/span&gt;
            &lt;span class="c1"&gt;//increment the respective elements' value of the frequency object&lt;/span&gt;
            &lt;span class="nx"&gt;frequency&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="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;frequency&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="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&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="c1"&gt;//If you run into number for the first time&lt;/span&gt;
            &lt;span class="nx"&gt;frequency&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="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&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;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After that, I tried checking each entry of the frequency object and then sort the elements based on the number of occurrences.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;//Create a 2D array based on &lt;/span&gt;
&lt;span class="c1"&gt;//the number of occurrences of the elements, e.g. make the object iterable&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sortedValues&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="nx"&gt;entries&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;frequency&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;sort&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="o"&gt;=&amp;gt;&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="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&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="mi"&gt;1&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;Yes, but right now I have one weird looking two dimensional array, in which, each element is also an array that holds the again the information about frequency. So, I just created another array which is going to be filled based on the numbers' occurrences.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Here, for each element of our 'sortedValues' 2D array,&lt;/span&gt;
&lt;span class="c1"&gt;// I populate the element as many as of its number of occurences,&lt;/span&gt;
&lt;span class="c1"&gt;//then creating a flattened array at the end(the part with reduce and concat)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sortedArr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;sortedValues&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sortedValue&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; 
&lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sortedValue&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]).&lt;/span&gt;&lt;span class="nx"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sortedValue&lt;/span&gt;&lt;span class="p"&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;reduce&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="o"&gt;=&amp;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;concat&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="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;So, the resulting array that I acquire after this step is the expected result.&lt;/p&gt;

&lt;p&gt;Solution link: &lt;a href="https://repl.it/@TahsinYazkan/Sort-an-array-by-frequency-and-value"&gt;https://repl.it/@TahsinYazkan/Sort-an-array-by-frequency-and-value&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you bear with my writing up until this point to finish reading my post with a minimum about of eye-rollings and yikes, thanks a lot!&lt;/p&gt;

&lt;p&gt;It really means a lot for me, because this is my first public post on this planet :D and I am talking about some technical subjects for the first time in my life and English is obviously not my mother tongue.&lt;/p&gt;

&lt;p&gt;If you have any questions and any problems, shout at me through private message or in the comments.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>algorithms</category>
      <category>sorting</category>
      <category>interview</category>
    </item>
  </channel>
</rss>
