Last active
December 3, 2023 09:00
-
-
Save phptuts/cf0cad3ee8cbb58bfde42509e5e7c6e5 to your computer and use it in GitHub Desktop.
Day 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log("Hello World"); | |
console.log("Hello World"); | |
console.log("Hello World"); | |
console.log("Hello World"); | |
console.log("Hello World"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// let age = 33; | |
// if (age > 18) { | |
// console.log('You can enter!'); | |
// } | |
// let luckyNumber = 7; | |
// if (luckyNumber != 14) { | |
// console.log('You are lucky'); | |
// } | |
// if (true) { | |
// console.log('This will log no matter what!'); | |
// } | |
// let oldEnough = age > 18; | |
// if (oldEnough) { | |
// console.log('You can enter!'); | |
// } | |
if (4 != 5) { | |
console.log('4 != 5'); | |
} | |
if (4 == 4 || 'hi' == 'hello') { | |
console.log('one of these are true, lol'); | |
} | |
let age = 4; | |
let name = 'Brittany'; | |
if (age > 3 && name == 'Brittany') { | |
console.log("It's your birthday!"); | |
} | |
let isRaining = false; | |
if (isRaining) { | |
console.log("bring umbrella"); | |
} | |
if (!isRaining) { | |
console.log("enjoy the sun"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// if (false) { | |
// console.log('this ran in the if'); | |
// } else { | |
// console.log('this ran in the else'); | |
// } | |
if (4 == 4) { | |
console.log('This will run this if'); | |
} else { | |
console.log('js can not do math!'); | |
} | |
let age = 13; | |
if (age > 18) { | |
console.log('you may enter'); | |
} else { | |
console.log('you are too young :('); | |
} | |
let iLikePizza = true; | |
if (!iLikePizza) { | |
console.log(":("); | |
} else { | |
console.log(":)"); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// let age = 45; | |
// if (age > 60) { | |
// console.log('Golden years'); | |
// } else if (age > 50) { | |
// console.log('Prime years'); | |
// } else if (age > 40) { | |
// console.log('Great years') | |
// } else { | |
// console.log('Young Years'); | |
// } | |
let name = 'Billy'; | |
if (name == 'Amy') { | |
console.log('You are awesome'); | |
} else if (name == 'Tom') { | |
console.log('You are great'); | |
} else if (name == 'Bill') { | |
console.log('Hi Bill!'); | |
} else if (name == 'Ash') { | |
console.log('You are rocking it!!'); | |
} else { | |
console.log('I do not know'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// let name = 'Tom'; | |
// switch(name) { | |
// case 'Bill': | |
// case 'Fred': | |
// console.log('Your name is Bill or Fred'); | |
// break; | |
// case 'Amy': | |
// console.log('Your name is Amy'); | |
// break; | |
// default: | |
// console.log('Your name is not known'); | |
// break; | |
// } | |
let train = 'redish'; | |
switch(train) { | |
case 'blue': | |
console.log('Bluezy Train'); | |
break; | |
case 'red': | |
console.log('Red Power Train'); | |
break; | |
default: | |
console.log('The Amazing Train'); | |
break; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for (let i = 0; i <= 10; i += 2) { | |
// console.log(i, 'running the loop'); | |
// } | |
let colors = ['yellow', 'green', 'blue'] | |
// for (let i = 0; i < colors.length; i += 1) { | |
// console.log(colors[i]); | |
// } | |
for (let i = 15; i >= 0; i -= 3) { | |
console.log(i); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// let person = { | |
// name: 'Fred', | |
// age: 50 | |
// }; | |
// for (let key in person) { | |
// console.log(key, person[key]); | |
// } | |
// let colors = ['green', 'red', 'blue']; | |
// for (let key in colors) { | |
// console.log(key, colors[key]); | |
// } | |
let dog = { | |
name: 'Fred', | |
furColor: 'green', | |
age: 4 | |
}; | |
for (let property in dog) { | |
console.log(dog[property], property); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let colors = ['red', 'green', 'blue']; | |
for (let color of colors) { | |
console.log(color); | |
} | |
let favoriteNumbers = [7, 1, 13]; | |
for (let num of favoriteNumbers) { | |
console.log(num); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// let i = 10; | |
// while(i > 0) { | |
// console.log(i); | |
// i -= 1; | |
// } | |
let j = 5; | |
while(j <= 10) { | |
console.log(j); | |
j += 1; | |
} | |
console.log('end'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for (let i = 0; i < 10; i += 1) { | |
// if (i == 5) { | |
// continue; | |
// } | |
// console.log(i); | |
// } | |
// let j = 5; | |
// while (j > 0) { | |
// j -= 1; | |
// if (j == 3) { | |
// continue; | |
// } | |
// console.log(j); | |
// } | |
let colors = ['red', 'green', 'blue', 'purple']; | |
for (let color of colors) { | |
if (color == 'blue') { | |
continue; | |
} | |
console.log(color); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for (let i = 0; i <= 10; i += 1) { | |
// if (i == 5) { | |
// break; | |
// } | |
// console.log(i); | |
// } | |
// let person = { | |
// name: 'Amy', | |
// age: 30 | |
// } | |
// for (let key in person) { | |
// if (key == 'age') { | |
// break; | |
// } | |
// console.log(key, person[key]); | |
// } | |
let colors = ['red', 'green', 'blue', 'yellow']; | |
for (let color of colors) { | |
if (color == 'green') { | |
break; | |
} | |
console.log(color, 'color'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a comment | |
/* | |
This is a long comment | |
Really long! | |
*/ | |
// Test Comment | |
/* | |
This is a | |
multi line | |
comment | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const coolName = 'Ash'; | |
const iLikeIceCream = true; | |
const coolColors = ['red', 'green', 'blue']; | |
const awesomePerson = { | |
name: 'Fred', | |
age: 23 | |
} | |
awesomePerson.age = 40; | |
coolColors[3] = 'purple'; | |
const iLikeChicken = true; | |
console.log(iLikeChicken); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hi() { | |
console.log('hi'); | |
console.log('hi again'); | |
} | |
function count() { | |
for (let i = 1; i <= 10; i += 1) { | |
console.log(i); | |
} | |
} | |
count(); | |
count(); | |
count(); | |
count(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// function count(countFrom, countTo) { | |
// for (let i = countFrom; i <= countTo; i += 1) { | |
// console.log(i); | |
// } | |
// } | |
// let maxCount = 50; | |
// count(1, maxCount); | |
function hi(name, age) { | |
console.log("hi, " + name + " you are " + age + " years old."); | |
} | |
hi("Amy", 34); | |
hi("Tom", 14); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add(num1, num2) { | |
// num1 = 3 | |
// num2 = 7 | |
// 7 + 10 | |
return num1 + num2; | |
} | |
let sum = add(3, 7); | |
function dogYears(age) { | |
// age = 37 | |
return age * 7; | |
} | |
let myYearsInDogYears = dogYears(37); | |
console.log(myYearsInDogYears, 'dog years'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// alert('Hi'); | |
// let name = 'Bill'; | |
// alert('Hi ' + name); | |
alert('You rock!!'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// let goForIt = confirm('Go for it?'); | |
// console.log(goForIt, 'go for it?'); | |
let iLikeIceCream = confirm('Do you like icecream?'); | |
if (iLikeIceCream) { | |
console.log('You know it!'); | |
} else { | |
console.log('You crazy!'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// let favoriteColor = prompt('What is your favorite color?'); | |
// console.log(favoriteColor, 'favoriteColor'); | |
let favoriteFood = prompt('What is your favorite food?'); | |
if (favoriteFood == 'Cheese') { | |
console.log('You are right!'); | |
} else { | |
console.log('Try again!'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// string = is text | |
console.log('Hello World'); | |
// number = | |
console.log(3); | |
console.log(33.23232); | |
// boolean | |
console.log(true); | |
console.log(false); | |
// add a string to a number | |
console.log('5' + 5); // 55 | |
// Math | |
console.log(5 + 5); // addition | |
console.log(5 - 5); // subtraction | |
console.log(5 / 5); // division | |
console.log(5 * 5); // multiplication | |
console.log("You rock!!"); | |
console.log(false); | |
console.log(82); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let firstName = 'Amy'; | |
// variable data type is a string / text | |
// variable name is 'firstName' | |
// variable value / data that it is store is 'Amy' | |
let age = 25; | |
// variable data type is number | |
// variable name is 'age' | |
// variable is storing 25 | |
let iLikeCheese = true; | |
// variable data type is boolean | |
// variable name is 'iLikeCheese' | |
// variable is storing true | |
age = 40; | |
let dogYears = age * 7; | |
console.log(dogYears); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let groceryList = ['apples', 'chicken', 'paper towels']; | |
console.log(groceryList[2]); | |
console.log(groceryList[1]); | |
groceryList[1] = 'vegatables'; | |
groceryList.push('flour'); // add an item to the end of the list | |
groceryList.pop(); // remove the item from the end of the list | |
groceryList.unshift('pizza'); // add an item to the beginning the of the list | |
groceryList.shift(); // add remove an item from the beginning of the list | |
console.log(groceryList); | |
let list = [3,4,32,4]; | |
list.push(22); | |
list.push(11); | |
list.unshift(33); | |
list.unshift(12); | |
list[2] = 77; | |
console.log(list); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let person = { | |
name: 'Ash', | |
age: 32, | |
address: { | |
street: '123 Main St.', | |
city: 'Santa Rosa', | |
state: 'CA' | |
} | |
}; | |
console.log(person.name); | |
console.log(person.address.street); | |
console.log(person['age']); | |
let pizza = { | |
topping: 'Onions', | |
cheese: 'Cheddar' | |
}; | |
console.log(pizza.topping); | |
console.log(pizza.cheese); | |
console.log(pizza); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(4 > 4, '4 > 4'); | |
console.log(4 >= 4, '4 >= 4'); | |
console.log(4 <= 4, '4 <= 4'); | |
console.log(4 < 4, '4 < 4'); | |
console.log(4 == 4, '4 == 4'); | |
console.log(4 != 4, '4 != 4'); | |
let age = 33; | |
let oldEnough = age > 18; | |
console.log(oldEnough, 'oldEnough variable'); | |
let favoriteNumber = 7; | |
console.log(favoriteNumber > 4, 'favoriteNumber > 4'); | |
console.log(favoriteNumber >= 4, 'favoriteNumber >= 4'); | |
console.log(favoriteNumber < 4, 'favoriteNumber < 4'); | |
console.log(favoriteNumber <= 4, 'favoriteNumber <= 4'); | |
console.log(favoriteNumber == 4, 'favoriteNumber == 4'); | |
console.log(favoriteNumber != 4, 'favoriteNumber != 4'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// console.log(!true); | |
// console.log(!false); | |
let darkTheme = true; | |
darkTheme = !darkTheme; | |
console.log(darkTheme); | |
let tooMuchPizza = false; | |
tooMuchPizza = !tooMuchPizza; | |
console.log(tooMuchPizza); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// console.log(5 > 4 && 5 < 6 && "hi" == "hi"); | |
// console.log(5 < 4 || 5 > 6); | |
// console.log(5 == 5 && 5 != 6); | |
// console.log(5 != 5 && "hi" == 'hi'); | |
// console.log('3' == '3' && true == true); | |
console.log(4 > 30 || 'hi' == 'hi'); | |
console.log(23 == 30 || 23 != 23); | |
console.log('bill' == 'bill' || 'tom' == 'ben'); |
Thx a lot this course was very helpfull
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
very good