Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
function checkForm() {
var formCount = document.forms.length;
if(formCount > 0) {
return true;
} else {
return false;
}
}
// AND/OR
var bool1 = true;
var bool2 = false;
if(bool1 && bool2) {
console.log("AND");
} else if(bool1 || bool2 && 1 > 3) {
console.log("OR");
}
// Ternary operators
var result = (bool1) ? "The expression is true" : "The expression is false";
console.log(result);
var personInfo = {
firstName: "Joe",
lastName: "Smith",
state: "CT",
zipCode: "06111",
fullName: function() {
return this.firstName + " " + this.lastName;
}
};
//JSON
var json = {
"firstName": "Joe",
"lastName": "Smith",
"state": "CT"
};
JSON.stringify(personInfo);
console.log(personInfo.firstName);
console.log(personInfo.fullName());
var array = ["CT", "MA", "NY", "RI", "NH", "VT", "ME"];
console.log(array.length);
var name = "Frank";
var length = name.length;
array.push("PA");
console.log(array);
array[0]; // "CT"
array[3]; // "RI"
delete array[1];
console.log(array);
array.splice(1, 1);
// var array = ["CT", "MA", "NY", "RI", "NH", "VT", "ME"];
//foreach
array.forEach(function(item) {
console.log(item + "!");
})
//DATES
personInfo.createdDate = new Date();
var date = new Date();
console.log(date);
var stringDate = new Date("02/24/2020");
var something = new Array();
//Try/Catch
try {
if(something.length > 0) {
alert('The array exists');
}
} catch {
console.log("There was an error in your try/catch");
}