This gif is completely irrelevant to the hw tonight, but might be relatable for some other things this week!
anyways!
This homework has two parts! The first part is practicing the javascript skills we learned today. The second part is to work on projects!
For this assignment, complete the problems below and add your solutions to this README.md.
*Without running the following code
*, try to determine:
var a = 1;
var b = 'bongos';
var c = true;
a = b;
b = c;
c = a;
### Your solution here:
1. What is `a`?
a is ('bongos')
2. What is `b`?
b is (true)
3. What is `c`?
c is (1)
Now run it and don't update your answers above. Any surprises? Don't worry about submitting wrong answers, it's all good :3
For the next problems, feel free to test out solutions in repl.it before putting your solutions in this readme!
## 2 - Activity Concatenation
Use the `+` operator to concatenate these strings together within a `console.log()`: "Please", "squeeze", "the", "cheese". __Make sure there are spaces in-between each word__.
```js
var firstWord = "Please";
var secondWord = "squeeze";
var thirdWord = "the";
var fourthWord = "cheese";
Result should be: "Please squeeze the cheese" console.log("Please " + squeeze + " the" + "cheese");
Output a console log The sum of 5 and 10 is 15
where the values for 5 and 10 are saved to variables, and where 15 comes from those variables being summed.
var num1 = 5; var num2 = 10;
Let's do this in parts:
-
How can we make
num3
equal to the sum ofnum1
andnum2
?num1 = "5" num2 = "10" num3 = num1+num2 15
-
Use variables
num1
,num2
andnum3
to fill in theconsole.log()
to complete the sentence:
The sum of 5 and 10 is 15
console.log(num3[5]+[10]);
By just looking at the following expressions, determine in your mind whether or not each will evaluate to true or false
a) 999 > 999
b) 999 === 999
c) 999 !== 999
d) -5 >= -4
e) 100 <= -100
f) 20 + 5 < 5
g) 81 / 9 === 9
h) 9 !== 8 + 1
Write true
or false
based on the list above
a) false
b) true
c) false
d) true
e) false
f) false
g) false
h) false
- Write a function called
timeTwo
that takes in a parameternum
andreturn
's that number multiplied by 2.
function timeTwo(a, b) return a2, b2;
- Write a
for
loop so that the function outputs all values between 0 and any number passed into themaxNum
parameter. for (var i = 0; i < 10; i++){ console.log(i); //outputs 0,1,2,3,4,5,6,7,8,9 }
- Create a variable
favoriteMovies
that is equal to an array of your 5 favorite movies:
var favoriteMovies = [‘Home Alone’, ‘pocahontas’, ‘Big Momma's Housw’, ‘Frozen’, ‘jumanji’ ];
- How would you replace the 3rd favorite movie with the value
Toy Story 3
?
favoriteMovies [2] = "Toy Story 3";
- How would you remove the last movie from that array?
favoriteMovies.pop();
- Write a function called
addMovie
that takes a parameter ofnewMovie
that adds that movie to the end of the array. addMovie('Titanic')) adds Titanic to the end of the array.
var addMovie = [[‘Home Alone’, ‘pocahontas’,'Titanic'] [‘Big Momma's Hous’, ‘Frozen’, ‘jumanji’]; newMovie[0][2] //=> 'Titanic'
newMovie[2].push('Titanic'); console.log(newMovie);
Let's keep trucking along with our projects! Our next project milestone is to have the a draft of the HTML/CSS. Your draft should be focused on the structure of your application, like placement of the headers, the main content, the nav, footer, etc. You should have a little bit of the text/content ready to go, but making sure you have a good layout is far more important at this point.
We are going to start looking at your project proposals tonight and will have all proposals addressed by tomorrow (Friday, April 12th) at noon!
To start your projects:
- Make a new folder on your computer called "Final Project"
- In that folder create files called
index.html
,style.css
andmain.js
- Do all if your work in the new
index.html
andstyle.css
files.
Your javascript exercises are due at midnight Saturday night!
Your project progress is due Sunday morning in class! We'll do submissions together that morning.