Week 3 - Finito! - Rock Paper Scissors Anyone?

Week 3 has concluded of the UT Bootcamp and I am still enjoying every minute. Besides the lack of sleep and the sure amount of mind-boggling information we have to take in, my mind is wide open to receive. This post includes a game...keep reading!

Bootstrap Portfolio Page

As week two wrapped we were asked to create a second portfolio page this time using the CSS library and pre-built framework Bootstrap. Still tweaking the video I created to put in as the header to make it responsive and making the portfolio pages link to places. Work in progress portfolio page.
It is still very much a work in progress but I suppose so is life.

Javascript

This week we started into the realm of javascript and boy am I excited. Javascript is considered to be one if not the (depending on who you ask) most prevalent, dominant and versatile language out there.

What is it? Wikipedia defines Javascript as

an object-oriented computer programming language commonly used to create interactive effects within web browsers.

It allows developers to create dynamic web applications capable of taking in user inputs, changing what’s displayed, crete animations and all sorts of fun things (which we are learning slowly).

Because Javascript has so many pieces and we have only touched on a few, below are a few basics that we have learned so far:

  • Variable or var: are the nouns of javascript and are 'things' and can be strings, numbers, booleans, etc. A variable has to be declared using var. For example var car = 'toyota';. This stores the string 'toyota' into the variable of car.

  • Arrays: are special variables that can store multiple values within a single variable. They can be numbers or strings or a mix. For example if you had more than one car you could store them in the variable car like this var car = ['toyota', 'ford', 'chevy'];

  • Objects : Objects are a type of an array and a type of variable. Where a variable can only hold one value an object can hold many values, like this: var car = {make: 'toyota', model: 'tacoma', color: 'black'}; . Values inside of an object can be anything including arrays, functions, variable and more.

  • Functions: are a block of code that are designed to perform a specific task. A function is executed when something calls it. It looks like this:

      function myFunction(make, model) {
         return make + model; }
    
  • If-Else statements: are conditional statements that perform different actions based on the conditions set. Basically you can think of it as if 'something' then execute a code block, otherwise (else) execute an alternate code block. If loops look like this:

      if (car.make===toyota){
          return true 
        }else 
         return false
    
  • The For loop : is used when you want to run a block of code multiple times. The syntax looks like this:

       for (i=0; i< car.length; i++){
          text += cars[i] + <"br">; 
        }
    

This sets the initial value to zero i=0 and then for as long as i is less than the length of our car array it will increment the function by one (i++). Then it will return the three values in our array car.

For loops are a little more complicated and you can read more about them and all of the others discussed herein at Mozilla Developer Network

The DRY Principle

This is a programming principle that says Don't Repeat Yourself'. Which means always try to find ways to keep your code clean. If you write a function multiple times, the DRY principle applied would be to figure out how to reduce the number of times you needed to write that function into one.

Game Time

As a mini-project we were asked to use what we learned in the first few classes of Javascript and create a basic rock paper scissors game. Try your luck playing the computer in this virtual rock paper scissors game.

See the Pen Bootcamp_3.2_RockPaperScissors by Nigel Finley (@Nfinleymusic) on CodePen.

Week 4 continues with Javascript and a hangman game. Stay tuned and brush up on your 2000s pop stars if you want to win hangman!!


Shout Outs