<?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: Malik Daliet</title>
    <description>The latest articles on Forem by Malik Daliet (@malik_daliet).</description>
    <link>https://forem.com/malik_daliet</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%2F3458909%2Fcb4366c8-71a1-45e0-962a-4ddf3eeabc8e.png</url>
      <title>Forem: Malik Daliet</title>
      <link>https://forem.com/malik_daliet</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/malik_daliet"/>
    <language>en</language>
    <item>
      <title>Map() and Filter()</title>
      <dc:creator>Malik Daliet</dc:creator>
      <pubDate>Sun, 09 Nov 2025 19:29:15 +0000</pubDate>
      <link>https://forem.com/malik_daliet/map-and-filter-1ao1</link>
      <guid>https://forem.com/malik_daliet/map-and-filter-1ao1</guid>
      <description>&lt;p&gt;Hey guys, I will be doing my blog on the map and filter array methods because I struggle to grasp and remember what map and filter actually does, and this will help me and other people understand better. I hope you guys enjoy!&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;What is the Map Method/ What does it do?&lt;br&gt;
*&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Map basically takes items in an array, copies them, and then modifies them. Map also iterates an array, uses callbacks (mainly anonymous functions), and returns the callback. If you forget to return, the new array will contain undefined.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;What is the Filter Method/ What does it do?&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
Filter is kind of like a strainer because it sifts/ filters what we want from an array. The filter() function also searches an array and returns the array. Filter also loops/ iterates through elements in an array.&lt;br&gt;
When using filter, the function callbacks returns a boolean. &lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Why/How I Used Filter and Map&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var friends = [
  {
    name: "Donal",
    age: 18,
    gender: "male"
  },
  {
    name: "Jonathan",
    age: 18,
    gender: "male"
  },
  {
    name: "Sunni",
    age: 19,
    gender: "female"
  }
];

var s = friends
  .filter(friend =&amp;gt; friend.age &amp;lt; 18)
  .map(friend =&amp;gt; friend.name);

console.log(s);

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

&lt;/div&gt;



&lt;p&gt;In this example, the end result is getting the age of a friend if their over 18 and if their gender is female. Like I said earlier, when trying to get objects, you use filter to get the whole object, then we use map to get the specific value, and then return. &lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Recreation Map&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const mentalLoad = [
  { type: "conflict", value: "argument with friend" },
  { type: "stress", value: "upcoming test" },
  { type: "focus", value: "finish homework" },
  { type: "stress", value: "chores pileup" }
];

const focusedItems = mentalLoad.filter(item =&amp;gt; item.type === "focus");
const tasksToFocusOn = focusedItems.map(item =&amp;gt; item.value);

// Final result:
console.log("Today, I will focus on:", tasksToFocusOn[0]);

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

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;Recreation of Filter&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Array.prototype.myMap = function(callback) {
  const result = [];

  for (let i = 0; i &amp;lt; this.length; i++) {
    // call the callback on each item and push its return value
    result.push(callback(this[i], i, this));
  }

  return result; // return the new array
};

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

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;Times When Filter Wouldn’t be the Best Fit&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
We would want to avoid using filter when we want to modify the existing array. If we’re/ your’re looking for just one item/ value, filter might be inefficient or going overboard. &lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Times When Map Wouldn’t be the Best Fit&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
We wouldn’t use map if we aren’t returning something because map expects us to return something. Not returning something results in undefined.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Comparison of Traditional Loops to Map and Filter &lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
Map and filter are simply more efficient. Traditional loops require you to write out the conditions, needs more code, and is only good for complex logic, unlike map and filter.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;If I were to Relay this to Real-World Problems &lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
One would filter out their stress/ conflicts so that they can focus on what matters. The connection with that would be filtering through stress/conflicts, but our end result we want would be focus. The array would contain our stress/ conflicts along with the thing we are trying to focus on, and we would filter out stress and conflicts. We would then get the this we are focusing on and say if we wanted a specific task to focus on, we would map to get that specific value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Array.prototype.myFilter = function(callback) {
  const result = [];

  for (let i = 0; i &amp;lt; this.length; i++) {
    const currentValue = this[i];

    // If callback returns true, keep the value
    if (callback(currentValue, i, this)) {
      result.push(currentValue);
    }
  }

  return result; // return the filtered array
};

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

&lt;/div&gt;



</description>
      <category>programming</category>
      <category>javascript</category>
      <category>career</category>
      <category>gamedev</category>
    </item>
    <item>
      <title>Malik's experience with code</title>
      <dc:creator>Malik Daliet</dc:creator>
      <pubDate>Sun, 07 Sep 2025 21:41:39 +0000</pubDate>
      <link>https://forem.com/malik_daliet/maliks-experience-with-code-1oh0</link>
      <guid>https://forem.com/malik_daliet/maliks-experience-with-code-1oh0</guid>
      <description>&lt;p&gt;I got into coding because I was curious about how phones work. I remember that day clearly. I was at the bus stop on Rampart with my mom, and I was on her phone, watching YouTube. I searched “how to make a game”. It was like a 6-minute video explaining the steps to make games, and I would watch it religiously, telling my mom, “I need a lot of money, a computer, and I need to market. She would just listen to me yap about for hours on end. Literally once a month, I would remember I wanted to make games and tell her because I was passionate about it.&lt;/p&gt;

&lt;p&gt;My coding introduction started in 7th grade in science class. We used an app/ website called Scratch. It’s a trash coding website, and I didn’t know what I was really doing on there, but I remember my old friend Caleb recorded his laugh on the app and got it to play. He sounded like SpongeBob, it was funny. In  8th grade, it was about the same, but it wasn't fun because nothing was explained at all, so I was very confused. In 8th grade, I also got a desktop, so I felt like I could finally start coding and do what I really wanted to do. I used to watch this YouTuber called Dani &lt;a href="https://www.youtube.com/@Danidev" rel="noopener noreferrer"&gt;YouTube&lt;/a&gt;, and he made his games on Unity, so I downloaded Unity. I didn’t have a clue what I was doing, but I managed to download a bunch of assets for characters. I specifically remember placing a tank down, but being completely confused about what I was looking at because they had a lot of words on there that I couldn’t even fathom. &lt;/p&gt;

&lt;p&gt;I have about 5 years of coding experience, starting from my freshman year till now. I started learning code from my teacher, Mr. Whitehead, and we used a site called &lt;a href="//code.org"&gt;Code&lt;/a&gt;. It was AP computer science. I struggled, but I failed the exam. I saw Mr. Greg at the pathway thing we had, and I was interested in Operation Spark. One of the teachers told me I should do it, but the paper she gave me, I missed the deadline was already over, but I got scared and wussed out. My sophomore year, I did AP computer science and failed the exam again, then I signed myself up for Operation Spark, and I passed the class easily with no sweat, besides HTML and CSS. I attempted to do Operation Spark again, but that was level 1, so I had to go back to being a normal student. Until my principal saw me one day and said, “Malik, you're smart, why don’t you join the robotics team?”, I said, “sure” because there wasn't anything else to do. In robotics, we use Java to code the robot, but I didn’t know Java. Since I’m the only one on the team who knew how to code, I was appointed coding team captain, and I tell you, I was stressed. I had to interpret a language I didn’t understand with a language I wasn’t fully literate in. One of the biggest skills I learned in my two years of robotics is stress management and teamwork.&lt;/p&gt;

&lt;p&gt;My biggest struggles when it comes to coding don’t even stem from coding; they come from injuries I sustained. While I was trying to complete level 2 for the first time, I was suffering the effects of a concussion I received. It damaged my brain to the point that I would forget what I just learned 1 minute after. My second attempt, I got concussed for a third time, so I failed yet again because my brain was so messed up to the point I started losing hope in my dreams. Then, while I was waiting to get my exam result, I got hit by a car, and still to this day, I have a hole in my knee. My third attempt, I also failed again, but I steeled my resolve to pass level 2, and on my fourth attempt, I did it just barely. I also started to feel cursed because every time I started Spark, something always happened to me without fail.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
