Lecture
This week will be talking about decisions and loops using JavaScript. Decisions are made in code using if statements, i.e. if this value is 5 or above make the background blue if its below 5 make the background red. Loops are one of the main things that makes programming great! We can loop through a large number of tasks and the computer will do those tasks pretty much instantly. For this we use something called a for loop or a while loop.
In Class Assignment
Create a wall paper pattern using loops, if statements and arrays. Try to play with Math.random() as well to create random patterns. Feel free to use images or divs to create this design.
Homework
Create an array of 8 images, double the items in the array by using the “push” function, shuffle the array using a shuffling function and use a loop to place them in the browser window with a unique id and data-id attribute for the two duplicated images. To do this create an array of image objects that have a image file property and a data-id property. Read chapter 4 for a better understanding of decisions and loops.