JAVASCRIPT STUFF!

This site is meant to help those that are just starting out or interested in JavaScript by showing a few different concepts that are used for pretty much everything.


Top Picks


Functions

Functions allow us to execute some action or actions and they are able to be used in a repeated fashion. They are the lifeblood of your program, but they must be called!
and they are used everywhere! Go to any site, and functions are firing. In the example below, we are trying to create a function that when called, will say "Hello, my name is Tom McClellan."
So first, we named our function, then entered our perameters that we have defined as Tom and McClellen. Then, when we call our function, it should introduce itself.

            
        function firstLast(first, last){
        let fullName = first + ' ' + last;
        console.log(`Hello, my name is ${fullName}.`);
            }
                    
        firstLast('tom' , 'mcclellan');
        firstLast('allie' , 'walker');
            
        

Objects

Objects are containers that let us store a collection of different datatypes, properties and methods. Below I have included and example of an object.
We have burritosNow and different data inside of it including size, quantity and our boolean of true. In the console.log, I asked for
burritosNow which will give me all of the information that is included. When I ask for "typeof" burritosNow, if will give me a list of information
as well as let me know that the "typeof" is an object.

                
        let burritosNow = {
        size: 'Large',
        quantity: 4,
        now: true
            };
        console.log(burritosNow);
        console.log(typeof burritoesNow); //OBJECT
                
            

Arrays

An array is a numerically indexed map of values that are inside square brackets. Starting out, it's easier to just say
it's a great way to collect a bunch of values together. They allow us to collect things
like names, usernames, product names, prices, etc. In the lists below, we know that we are working with arrays because of the [] square brackets.

                
        let long = [1,2,3,4,5,6,7,8,9,10]
        console.log(long.length);
                    
        let colors= ['blue' , 'green' , 'yellow' , 'red' , 'orange'];
        console.log(colors.length); //6
        console.log(typeof colors); //object
        console.log(typeof colors.toString());
                
            

Conditionals

Conditionals are used to check certain conditions in your application. Conditionals have the power to alter the state of your application
based on certain conditions being met or unmet, true or untrue. In the example below, we have our variable "weather" which is equal to 75.
We have our if statement that tells us that if the weather is GREATER THAN 70, to let us know to wear shorts.
When we run our function, because 75 is greater than 70, we will be alerted to wear shorts!

            
    var weather=75;

    if(weather > 70){
    console.log("Wear shorts today! It's going to be hot!");
                    
        }