Skip to content

Commit 4d25d95

Browse files
committed
w2 done
1 parent de88b6e commit 4d25d95

File tree

21 files changed

+496
-0
lines changed

21 files changed

+496
-0
lines changed

Diff for: week2-datatypes_functions/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Week 2
2+
3+
## Objectives
4+
- I can control program flow using while loops
5+
- I can create custom functions.
6+
7+
8+
9+

Diff for: week2-datatypes_functions/donow/donow.html

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<html>
2+
<head>
3+
<title>do now</title>
4+
</head>
5+
<body>
6+
<script type="text/javascript" src="donow.js"></script>
7+
</body>
8+
</html>

Diff for: week2-datatypes_functions/donow/donow.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
var cash = 15;
2+
3+
var numCandyBars = prompt('How many candy bars do you want to buy?')
4+
5+
var cost = numCandyBar * 0.75;
6+
7+
cash = cash - cost;
8+
alert = cash;
9+
10+
if(cash = 0){
11+
alert('you're out of money!')
12+
}
12 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<html>
2+
<head>
3+
<title>functions demo</title>
4+
</head>
5+
<body>
6+
<h1>Open the console</h1>
7+
<script src="functions_demo.js"></script>
8+
</body>
9+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
console.log('working');
2+
3+
// super simple
4+
// this function will just alert "hello" when called
5+
6+
// Function to see if two numbers are even
7+
// use the % operator
8+
9+
// Function that will return a random number up to a given value
10+
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<html>
2+
<head>
3+
<title>blondie</title>
4+
</head>
5+
<body>
6+
<h1>Functions Practice</h1>
7+
<p>Open your console to check your code</p>
8+
<script type="text/javascript" src="functions.js"></script>
9+
10+
</body>
11+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Less Than
2+
// - Write a function min that takes two arguments and returns the small value.
3+
4+
// Fizz Buzz
5+
// - Write a function that takes in a test number.
6+
// - If the number can be divided by 3 with no remainder, print "fizz"
7+
// - If the number can be divided by 5 with no remainder, print"buzz"
8+
// - If the number is divisible by both 5 and 3, print "fizzbuzz"
9+
// HINT, check out the % operator
10+
// Challenge, use while operator to check values 0 to 100
11+
// Make sure you have a check to stop the while loop
12+
13+
// TuTone (Challenge!)
14+
// - create a function called "jenny" that simply returns "867-5309" when called.
15+
// - Write another function called "tommy" that takes the jenny function as a parameter.
16+
// - store a message, "Jenny I've called your number " + and then execute the telephone function passed to it.
17+
// - alert the message
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<html>
2+
<head>
3+
<title></title>
4+
</head>
5+
<body>
6+
<h1>Open the Console!</h1>
7+
<p>On a mac, ctrl + click anywhere then choose inspect</p>
8+
<p>On a pc, right click anywhere then choose inspect</p>
9+
<script src="logic_demo.js"></script>
10+
</body>
11+
</html>

Diff for: week2-datatypes_functions/logic/logic_demo/logic_demo.js

Whitespace-only changes.
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function updateItems() {
2+
hasBacon = document.getElementById("bacon").checked;
3+
hasLettuce = document.getElementById("lettuce").checked;
4+
hasTomato = document.getElementById("tomato").checked;
5+
hasCheese = document.getElementById("cheese").checked;
6+
hasKale = document.getElementById("kale").checked;
7+
hasAvocado = document.getElementById("avocado").checked;
8+
hasPeanutButter = document.getElementById("pb").checked;
9+
hasBanana = document.getElementById("banana").checked;
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<html>
2+
3+
<head>
4+
<title>blt</title>
5+
</head>
6+
7+
<body>
8+
<h1>Sandwich Checker</h1>
9+
<form>
10+
<input type="checkbox" id="bacon" value="bacon">
11+
<label for="bacon">bacon</label><br>
12+
<input type="checkbox" id="lettuce" value="lettuce">
13+
<label for="lettuce">lettuce</label><br>
14+
<input type="checkbox" id="tomato" value="tomato">
15+
<label for="tomato">tomato</label><br>
16+
<input type="checkbox" id="cheese" value="cheese">
17+
<label for="cheese">cheese</label><br>
18+
<input type="checkbox" id="kale" value="kale">
19+
<label for="kale">kale</label><br>
20+
<input type="checkbox" id="avocado" value="avocado">
21+
<label for="avocado">avocado</label><br>
22+
<input type="checkbox" id="pb" value="pb">
23+
<label for="pb">peanut butter</label><br>
24+
<input type="checkbox" id="banana" value="banana">
25+
<label for="banana">banana</label><br>
26+
<button onclick="checkSandwich()">Check Sandwich</button>
27+
</form>
28+
<script src="sandwich.js"></script>
29+
<script src="input.js"></script>
30+
</body>
31+
32+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//will be true if the box is checked, will be false if not
2+
var hasBacon, hasLettuce, hasTomato, hasCheese, hasKale, hasPeanutButter, hasBanana;
3+
4+
//this function will be called when the button is clicked
5+
function checkSandwich() {
6+
updateItems(); //this will update the values, see input.js if you are interested to see how.
7+
8+
// Your Turn!!!
9+
10+
//if all bacon lettuce and tomato are all true, alert the user that this is a blt
11+
//else, alert that user that this is not a blt
12+
13+
//if the sandwich doesn't have bacon, alert that it is vegetarian
14+
//else, alert that it is not vegetarian
15+
//use the ! (not operator)
16+
17+
//if kale or avocado are true, alert the user that this sandwich has superfood
18+
//else, tell them that it does not have super foods
19+
20+
//elvis worthy?
21+
//if the sandwich peanutbutter and has bacon or banana, alert that elvis would approve
22+
//else, alert that elvis wouldn't approve
23+
}

0 commit comments

Comments
 (0)