Rayhatron web developer banner

Javascript30 Day 7-Array Cardio 2

27 January 2017 - 2 mins read

Today’s challenge was the second installement of Array cardio.

Just like the first Array cardio day, I worked with various array methods to manipulate array data.

The two arrays that I worked with are as follows:


    const people = [
    {name: 'Ray', year: 1997 },
    {name: 'Kait', year: 1986 },
    {name: 'Irv', year: 1970 },
    {name: 'Lux', year: 2015 }
    
    ];

    const comments = [
        {text: 'Love this!', id: 523423 },
        {text: 'Super good', id: 823423 },
        {text: 'You are the best', id:  2039842},
        {text: 'Lasagne is my fav food ever', id: 123523 },
        {text: 'Nice Nice Nice', id: 542328 }
    ];

Now the tasks that I had to carry out are as follows:

  1. Use Array.prototype.some() to check if at least one person is 18?
  2. Use Array.prototype.every() to check if everyone is 19?
  3. Use Array.prototype.find() to find the comment with ID of 823423.
  4. Use Array.prototype.findIndex() to find the comment with ID of 823423 and delete it.

For all the tasks, I started by learning more about the method to be used on Mozilla Developer Network. This is a great resource to always keep in mind when developing because it’ll save you a lot of time when you get stuck as it explains clearly what you’re looking for.

The challenge was not that difficult as most of the array methods are straight forward in how they work. This 4 array methods together with the methods that I used in the previous array cardio make up a nice list of array methods that you should always keep in mind during development.

Today i learned:

  • MDN is a great reference resource
  • 4 more array methods
  • More ES6 style code

What other array methods do you find handy? Feel free to tweet @me about them. You can find the code here.