Week 4 - Movie Data 1
The Movie Data project is the most challenging one you’ll face!
We’re spending two weeks looking at it
We want you to know, it’s okay if you’re finding it difficult
🍿💛
let movieData = {
"The Darjeeling Limited": {
plot: "A year after their father's funeral, three brothers travel across India by train in an attempt to bond with each other.",
cast: ["Jason Schwartzman", "Owen Wilson", "Adrien Brody"],
runtime: 151,
rating: 7.2,
year: 2007,
},
//...
};
Arrays can be used to store multiple pieces of information in one variable
We use square brackets to define an array when we declare it
let myArray = [1, 2, 3, 4];
We access values by using indexes
In other words, where in the array we’re looking for the information
let myArray = [1, 2, 3, 4];
const myNum = myArray[0];
console.log(myNum);
// logs 1
Objects allow us to store multiple pieces of information by using keys and values
We use curly brackets to define an object
let myObject = {
name: "Fido",
type: "dog",
age: 4,
};
We reference keys to get values using square brackets or dot notation
let myObject = {
name: "Fido",
type: "dog",
age: 4,
};
console.log(myObject[name]);
console.log(myObject.age);
Properties can be:
An example of an in-built property is length
e.g.
let myArray = [1, 2, 3, 4];
let arrLength = myArray.length;
// what's the length here?
Methods are like functions, but are pre-defined in JavaScript
It’s likely you’ve used some methods already!
document.querySelector("p");
str.toLowerCase();
arr.sort();
W3 Schools and MDN have great resources on different JavaScript methods
Conditional statements let us define what should happen, if a condition is true
if (num > 6) {
array.push(num);
}