Exercises before Udacity’s Arcade Game Project

My goal for this week is to tackle down Udacity’s Arcade Game Project. I’ve been reading a lot of chapters and watching a lot of videos regards to Object Oriented Programming, JavaScript. However, these are way too passive. Before I get into LocalStorage etc. advanced concepts, I need to finish several mini-projects which are mainly focusing on applying OOP.

For now, my Dynamic Quiz is functional as expected. However, it is not included much OOP. The missing features of my Dynamic Quiz is localStorage and layout. So, I am gonna take a break from there at this moment. Because I feel that I lack in OOP skill.

When I opened Arcade Game original files from Udacity, I really have no idea where to start or how to read these files. I read it carefully one time. Then, I began to know what are the functions doing there. However, I still have no idea what I should create. Fortunately, I found a series of tutorials from Youtube that was related to this project. Even I finished reading the videos, I am still stuck to start.

I remember that there is a similar project from Eloquent JavaScript, so I decided to do EJ’s exercises before I start Udacity’s Arcade Game.

Here is what I’ve learned from EJ’s exercises.

Chapter 5 Higher-Order Function.

Array.prototype.reduce()

Example: Sum up all values within an array

var total = [0, 1, 2, 3].reduce(function(a, b) {
  return a + b;
});
// total == 6

Example: Flatten an array of arrays

var flattened = [[0, 1], [2, 3], [4, 5]].reduce(function(a, b) {
  return a.concat(b);
});
// flattened is [0, 1, 2, 3, 4, 5]

Array.prototype.concat()

var alpha = ['a', 'b', 'c'],
    numeric = [1, 2, 3];

var alphaNumeric = alpha.concat(numeric);

console.log(alphaNumeric); // Result: ['a', 'b', 'c', 1, 2, 3]
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s