Skip to content

Create James #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions James
@@ -0,0 +1 @@

15 changes: 15 additions & 0 deletions index.html
@@ -0,0 +1,15 @@
<!doctype html>

<html>
<head>
<link rel="stylesheet" href="main.css">

</head>

<body>



</body>
<script src="intermediate.js"> </script>
</html>
78 changes: 78 additions & 0 deletions intermediate.js
@@ -0,0 +1,78 @@
//and &&
//or || (above enter key)

var bool1 = true
var bool2 = false

if (bool1 && bool2) {
console.log("AND")
} else if(bool1 || bool2) {
console.log("OR")
}

// Ternary Operators
var result = (bool1) ? "The expression is true" : "The result is false";
console.log(result);

var profile = {
firstName: "Mark",
lastName: "Wahlberg",
state: "CT",
zipCode: "06269",
fullName: function() {
return profile.firstName + " " + this.lastName; //putting this.item is the same as putting the variableName.item
},

};

console.log(profile);
console.log(profile.fullName());

var array = ["CT", "MA", "NY", "RI", "NH", "VT", "ME"];

console.log(array.length); //length is an attribute that can be referenced without it being an item of a variable

var name = "Frank";
var length = name.length;
console.log(length);

array.push("PA");

console.log(array.length); //push adds another item onto the array so now the length is 1 longer

console.log(array[0]);

delete array[1]; //deletes MA but leaves a "hole", it will leave the value but not the slot

array.splice(3, 1) //deletes an item and removes the slot from the list, location then number of items to be removed
console.log(array) //RI is gone now

array.forEach(function(item) {
console.log(item + "!");
})

//DATES

var date = new Date(); //current time
console.log(date);

var dateInput = new Date("02/24/2020") //easy way to set a date

try {
if (something.length > 0) {
alert('the array exists');
}
} catch {
console.log("there was an error in your try/catch")
}

//JSON
var json = {
"firstName": "Joe",
"lastName": "Smith",
"state": "CT"
};

JSON.stringify(profile);
console.log(profile);

Empty file added main.css
Empty file.