DEV Community

Cover image for JavaScript30 - 4 Array Cardio Day 1
VirtualSobriety
VirtualSobriety

Posted on

JavaScript30 - 4 Array Cardio Day 1

Let me just start by saying my initial thoughts about this challenge were completely wrong. I figured this would be the easiest challenge BY FAR and was expecting to complete it and write this post in the same day. Here I am, almost two weeks later having just finished watching Wes Bos's video with his solutions.

He was absolutely right calling this Array Cardio because it was a workout for sure. Plus it reminded me, not so gently, how little I know about arrays, how they work and what you can do with their sweet sweet information.

    const oldPeople = inventors.filter(function (person){
      if (person.year < 1600) {
        return person.year > 1500;
      }
    } )
    console.log(oldPeople)
Enter fullscreen mode Exit fullscreen mode

I guess we should basically start at the top and take it from there...This challenge obviously had us working with arrays from start to finish in many ways I never knew possible. It covered different tasks that started with filtering names from a given list to sorting different street names from a Wikipedia page in real time.

  const fifteen = inventors.filter(inventor => (inventor.year >= 1500 && inventor.year < 1600));

    console.table(fifteen);
Enter fullscreen mode Exit fullscreen mode

The exercises covered four different ways to manipulate data within an array, those being: filter, sort, map and reduce. There were 8 exercises in total and I mostly struggled with number 6 which had you go to this link right here and work solely in the console to take the information off the page, turn it from a node into an array and then list out the necessary information. I missed the fact that the data in the array was pretty obviously an object and eventually moved on without finding a perfect solution on my own/with the help of google.

Despite being stumped on one question I did manage to solve the other 7 exercises on my own. Very few of my solutions matched Wes's but that's part of the fun! I would probably have been a bit letdown if I saw that I came up with the exact same answer, as by the time I completed this challenge I now had two different ways to complete each task.

The console.table is a complete gamechanger!

I do have to give a HUGE shoutout to one part of this challenge in particular. This was when Wes introduced the console.table() command. I knew console.log() was a huge tool in coding but never knew there were more variations to the console commands. Looking back at it now it's pretty obvious that there would be different ways to show information in the console but it never occurred to me that they could be so different and helpful. I definitely want to do a quick dive into different console commands just to see what else I can do, as this simple change from .log to .table completely blew my mind!

This challenge was a toughie and I am exhausted. I spent days upon days working on this. I should start leaving my expectations at the door when I think about coding and how the rest of this course will be because I couldn't have been more wrong by assuming this would be quick and painless. I am excited to work on something a bit more tangible with the next challenge: Flex Panels Image Gallery! I'll see you then!

the next lesson!

Top comments (2)

Collapse
 
ax17 profile image
Alex • Edited

this seems a very productive challenge, happy to see how much you practiced and learnt. You explained very well, for me is also understandable

Collapse
 
virtualsobriety profile image
VirtualSobriety

Thank you for the kind words! The challenge was definitely tough but I do recommend trying it if you have the chance!