Apply for the next session

Lesson Intro

Derek has a lot of very interesting stuff on his desk. Let’s talk about it!

Also: Because this is JavaScript (and everything is secretly an object) – an array is no different – and it has many very cool array functions (methods).

Ivy says

Will ya set a timer and tell us how long it takes to watch this video and do the follow-along parts? Thanks!

We find ourselves using these ones the most:

array.from(), array.isArray(), array.length

array.push(), array.shift()

array.join(), array.reverse(), array.find(), array.filter(), array.forEach(), array.map(), array.reduce()

Now, we – are showing you these – in order – on purpose. So, we don’t want to hear about all of the “other things” that you tried. Just stick with these. Today is all about these.

We expect map and reduce to be pretty tricky! We’ll be talking about those in detail later — but try and try them all out.

Exercises:

  1. Watch the video and follow along

    Make sure to take a break – and make sure your data is unique to you.

    120 minutes suggested
  2. Try out all of the array properties and methods

    Get with a buddy and go over them one by one. Try and find a real-world use case for each / based on the projects you are building.

    120 minutes suggested

Newly introduced language features

  1. JavaScript

    Array filter

    // array.filter(conditionFunction); // returns a new array of items that match the condition
    
    var numbers = [5, 10, 35, 12, 45];
    
    var higherNumbers = numbers.filter( function(item, index, array) {
    	if (item > 30) {
    		return item;
    	}
    });
    
    console.log( higherNumbers ); // [35, 45]
    
    
    
    function isHighNumber(number) {
    	if (item > 30) {
    		return item;
    	}
    }
    
    var higherNumbers = numbers.filter(isHighNumber);
    
    console.log( higherNumbers ); // [35, 45]
Apply for the next session