JAVASCRIPT 4 DUMMIES


just a scrub helping his fellow scrubs unscrub themselves


2 REALLY dumb it down


FUNCTIONS

I know it looks like a lot, but functions are actually a very cool thing. To try and make it English for us dummies, we are able to use these to create a "sub-code" with it's own rules, name, and variables. But by doing this, we are able to pull that little "sub-code" out any anytime by name to do exactly what we have designed for them to do.


ARRAYS

Think of an array as essentially being a list that can be filled with almost any type of data that you want. Don't get too ahead of yourself though, you have to make sure that they are correctly made. The easiest way that you can tell an array is being used is because they must always utilize SQUARE BRACKETS( [] ). The other key thing that you need to make sure that you always remember is that each item in the array is numbered with an index. That index number will always start with 0, and then from there you are able to count up. Just think that when you normally count, the actual number of the item is one number behind what you are thinking.


FOR LOOPS

For Loops. Don't overthink it. All it does it continuously loop. Until it hits a stopping point that you set up of course. You can use for loops for simple things like adding, subtracting, timers, adding items to an array, if you can think it, then usually a for loop can help you accomplish it. As for that continuous loop that I spoke of though, it WILL do that. Unless you set up stopping parameters for it. Such as if you wanted a 30 second countdown timer on it, then you can have it so that it just starts out at thirty, every loop will subtract by one, and will end when the timer hits zero.SS