Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## JSDR213
## SEBR 0116

# Conditionals and Loops Lab

Expand Down Expand Up @@ -34,13 +34,14 @@ Run a For Loop that starts at 0, ends at 10, and logs each number squared (your

## 7 - F F F Foods

Create an array of foods, then loop through them. Run a conditional in your loop with the charAt[0] method so that you are only logging to your console foods that start with the letter F
Create an array of foods, then loop through them. Run a conditional in your loop with the charAt(0) method so that you are only logging to your console foods that start with the letter F

## 8 - Even and Odd Numbers
## Bonus 8 - Even and Odd Numbers

Run a loop that goes between 20 and 40, but only logs Even numbers. Then create a new loop that does the same for Odds


## 9 - FizzBuzz!

## Bonus 9 - FizzBuzz!

A coding classic, run a loop that counts and logs every number between 1 and 30. If a number is divisible by 3, log "Fizz", if it is divisible by 5, log "Buzz", and if it is divisible by 3 and 5, log "FizzBuzz"
67 changes: 67 additions & 0 deletions conditionandloopshw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//prompt 1
let Temperature = 72;

if (Temperature > 75) {
console.log("It is warm!");
} else {
console.log("It is cold.");
}
//prompt 2
let softballTeam = ["Alice", "Bob", "Charlie", "Diana", "Eve", "Frank", "Grace", "Henry", "Iris"];

if (softballTeam.length >= 9) {
console.log("Play ball!");
} else {
console.log("Not enough players!");
}
//prompt 3
let grade = 88
if (grade <=100 && grade >=90) {
console.log('You have an A!')
} else if (grade < 90 && grade >= 80) {
console.log('You have a B!')
} else if (grade < 80 && grade >= 70) {
console.log('You have a C.')
} else if (grade < 70 && grade >= 65) {
console.log('You have a D')
} else if (grade <= 64 && grade >= 0) {
console.log('Failing Mark')
} else if (isNaN(NaN))
console.log('Please enter a valid grade')
//prompt 4
let checkingAccount = 500;
let savingsAccount = 1000;
let actionType = "Transfer";

switch (actionType) {
case "Withdraw":
checkingAccount -= 100; console.log("$100 withdrawn from checking account.");
console.log("Updated balances: Checking - $", checkingAccount, "Savings - $", savingsAccount);
break;

case "Deposit":
checkingAccount += 100; console.log("$100 deposited to checking account.");
console.log("Updated balances: Checking - $", checkingAccount, "Savings - $", savingsAccount);
break;

case "Transfer":
savingsAccount += 100; checkingAccount -= 100;
console.log("$100 transferred from checking to savings account.");
console.log("Updated balances: Checking - $", checkingAccount, "Savings - $", savingsAccount)
}
//prompt 5
for (let i = 0; i <= 50; i += 5) {
console.log(i);
}
//prompt 6
for (let i=0; i<=10; i++) {
console.log(i**2)
}
//prompt 7
let foods = ["Fries", "Pizza", "Salad", "Fish", "Tacos", "Burrito", "Falafel"];

for (let i = 0; i < foods.length; i++) {
if (foods[i].charAt(0) === "F") {
console.log(foods[i]);
}
}