
Before we are able to write a program in any language, we must learn the basic rules and building blocks.
Computers represent everything as 1’s and 0’s, this wouldn’t be acceptable for most humans. Programming languages have “types” of data, we will use different types to solve different sorts of problems. IE: Numbers are used for math, Strings for text.
A common pattern in programming logic (and real world logic) is making choices based from the answer to a true or false expression. For example, “is it raining? If yes, wear a raincoat”. Learn how to handle these type of logical decisions with JavaScript.
Typically, programs are created from many individual “routines” or “functions”. These are units of work. A good program has many functions that each do one small task, and can be used alone or combined with other functions to perform more complex tasks.
Mad-Libs are word games where funny stories can be generated. A person playing Mad-Libs will pick words at random, the words must be specific types, (that is; noun, verb, adjective). Then the words are used as replacements for blank words injected throughout the story.
Review the Assignment from Day 1
Lists are important in life and programming. Every program or website will have features that are best kept in collections, these are called Arrays in JavaScript. (Examples of data for a list could be posts, friends, dates, and so on).
When dealing with Arrays, we’ll often need to do some task on or with each individual item in the array. Since we don’t always know how many items are in an Array, and since we would be writing the same code over and over, instead we can use “loops”.
Sometimes we will need to make logical choices based on the value of a variable or expression rather than the truthfulness of it. For instance, depending on what day today is, we might cook different dinner. In JavaScript, conditions like this are handled with “switch” statements.
Although not very common, there will be times that we want to stop looping before every item has been iterated over, or we may wish to continue to the next iteration of a loop without running the rest of the code in the loop. For this we can use the “break” and “continue” keywords.
There are some functions that are so common, JavaScript includes them in the language. In this video we’ll go over a few and show how to use them to select random Array items.
Our assignment for day 2 will be to improve on the Mad-Libs assignment by using loops to choose the words.
Review the Assignment from Day 2
As we begin to model more complex problems and build complex solutions, we might want to group variables together in a common “namespace”. Remember the Math.random and Math.floor functions; they are on a part of the Math namespace.
Usually we will use objects to hold properties related to some part of a program, so it’s natural that we would end up running common functions with these objects. Lucky for us, we can benefit from putting these functions as properties of the object.
So far, everything we’ve done has been sequential work, each line ran directly after the other. Sometimes we’ll write code that doesn’t need to run immediately. Some examples are clocks, animations and time outs.
There are some things about using objects and writing object methods that cause many new developers lots of headaches. In this video we’ll explore some of these, namely, the function context “this”.
Sometimes we need to create many objects that represent very similar things. Think of users on a site, they would all have names, ids, friends, and they would also have common methods. This video explores an easier way to create common objects.
In this assignment, we will create a mini game that runs in the console. The game will create battleship objects, and then you (the player) should guess at the location of the ship, if the location is correct then you win the game, This game will be small, but it will be the foundation for other works.
Review the Assignment from Day 3
Ahh, finally we are ready to write code that has a visual aspect. In order to create layouts and interfaces in the browser we need to learn about the DOM, (document object model).
When styling HTML, we use CSS. CSS selectors are how we tell the browser which elements to target. Lucky for us, we can also use these selectors to reference HTML elements.
All this work with the DOM can become very nuanced, difficult and often overly complex. Lucky for use, there is a super powerful, and very commonly used library to assist us with tasks in the DOM.
One great benefit of using jQuery, is that cannot only easily select elements from the DOM, but also set and get values for DOM attributes as well. We can even change styles with jQuery.
There is so much that we can do with jQuery, In this assignment, you will create a website only using jQuery.
Review the Assignment from Day 4
When you go to a webpage or web app, the parts of the page that are dynamically created are likely represented in JavaScript using objects.
Human interaction with our apps and webpages will primary happen through either buttons or forms. Forms are a great way to collect information from users.
Another way that users will interact with our sites will be with mouse events. We can “listen” to any and all of these events. Listening to events is a very critical skill for JavaScript developers to learn
Just like click and touch events, when a form is submitted that triggers an event as well. We can listen for this event and use it to know when a user has finished filling out a form, then collect information.
Now that we are able to write code that can take data from user interactions and we can model data from JavaScript in HTML. This would be a great time to build a better battleship game.
Review the Assignment from Day 5
Often, we will need to get information from a site other than our own. Luckily the browsers have an API called fetch that makes this easy.
Sometimes we want to store information between browser refreshes. A very simple way to do this without a database is by using the browser as a data store.
So far we have been writing our own CSS and using jQuery to do animation. There are libraries that handle some of this for us, bootstrap is a popular library/framework that writes CSS for us and uses jQuery to create cool components like carousels.
Sometimes sites will allow us to show their content on our own sites. Think of YouTube, we see YouTube videos on other websites all the time, the videos are still hosted on YouTube even though we see them through a different site, this is called embedding.
Now we know how to create a carousel and we know how to listen for events with jQuery. Try to combine the two, create a carousel that can be controlled by our own JavaScript or that has call to action buttons to run dynamic code in our page.
Review the Assignment from Day 6
One problem all programmers have are bugs. Bugs can be difficult to handle.
Sometimes our code doesn’t have bugs that throw errors, sometimes it just doesn’t run the way we expect and it’s difficult to understand why. In this video we’ll see some advanced techniques for handling situations like these.
It’s time to use all we’ve learned to build a great project. We’ll create a page that stores journal entries about our development experiences and can even show us code embedded from Repl.it.
In this video, we’ll go over one version of the final project. Yours may be different.
JavaScript is the language of the web. You can use it to add dynamic behaviors, store information, and handle requests and responses on a website on-the-fly and this is why it has become one of the most useful languages in the web development community.
In this course, you will instantly start to work with JavaScript, jQuery, and Bootstrap using the in-browser editor. You'll start off by learning the basics of JavaScript by writing your first program. After mastering the fundamentals, you'll learn how to write clean and maintainable JavaScript code. You'll be taught modern JavaScript at a quick pace to maximize your learning for the time available. Later you'll work with objects and arrays to model problems/solutions for better program output in JavaScript. You'll be creating an awesome-looking battleship game with slideshows, a development journal with YouTube, and image-embedded URLs with Bootstrap and jQuery.
Each lesson will begin by reviewing the exercise from the previous day, before moving on to the subject of that day's lesson. By the end of the course you will be amazed by everything you've managed to learn and accomplish in such a short time. Each lesson is inspiring and fun, making you feel like a magical code wizard!
About the Author
Michael Rosata is a professional JavaScript developer and the author of three courses on Functional JavaScript. He’s written multiple JavaScript applications for internal use at large companies. Michael is the founder of the Massachusetts Web Devs meetup. He has a great passion for learning, and teaching
You can find him answering questions in the Ramda gitter channel or at michael.rosata@gmail.com
I’d like to thank my family for giving me the opportunity to explore things I enjoy learning, and to the team at Packt Publishing, especially Sunny Kandre and Anish Dsouza for making this course possible.