// Console.log() ise useful for printing values of variables or results into the browser's console.
letmyVariable;
myVariable='Hello';
// Trying to print out a value of a variable that has not been declared will return of "not defined"
console.log(myVariable);
// The "not defined" error in the console refers to the variable not being created /defined, whereas in the previous example the code refers to the "value" of the variable as not defiend.
lethello;
hello="Hello";
console.log(hello);
// Naming Variables
// let FirstName = "Michael"; - bad variable name
// let firstName = "Michael"; - good variable name
// let product_description = "lorem ipsum" good variable name
// Declaring and initializing variables
letproductName='desktop computer';
console.log(productName);
letseatsInTheatres='10';
console.log()
// let variable cannot be re-declared within its scope.
// let friend = 'kate';
// let friend = 'jane'; - would cause an error.
// console.log(friend);
letfriend='Kate';// Straight declaration
friend='Jane';
console.log(friend);
letsupplier;// Variable is a container
// Initialization is done after the variable has been declared.
supplier='John Smith Tradings';
console.log(supplier);
constinterest=3.539;
console.log(interest);
// You can't declare a const variable using initialization
// const pi;
// pi = 3.1416;
// console.log(pi);
// SECTION Data types
// Strings
letcountry='Philippines';
letprovince="Metro Manila";
// Concatenating strings
// Multiple string values can be combined to create a single string using + symbol.
letfullAddress=province+','+country;// use '' for as a string
console.log(fullAddress);
letgreeting='I live in the '+country;
console.log(greeting);
letstring="Hello";
letnumber=42;
letresult=string+" "+number;
console.log(result);
// Escape character "\"
letmailAddress='Metro Manila\n\nPhilippines';
console.log(mailAddress);
letmessage="John's employees went home early";
console.log(message);
message="John's employees went home early";// you can also use 'John\'s'
console.log(message);
// Numbers
// Integers / Whole Numbers
letheadcount=26;
console.log(headcount);
// Decimal Numbers/Fractions
letgrade=98.7;
console.log(grade);
// Exponential Notation
letplanetDistance=2e10;
console.log(planetDistance);
console.log("John's grade last quarter is "+grade);
// Boolean
// Boolean values are normally used to store values relating to the state of certain things, this would be useful for logics.
letisMarried=false;
letinGoodConduct=true;
console.log("isMarried: "+isMarried);
console.log("isGoodConduct: "+inGoodConduct);
// Arrays
/// Arrays are a special kind of data type that's used to store multiple values
// Arrays can store different data types but is normally used to store similar data types.
letgrades=[98.7,92.1,90.2,94.6];
console.log(grades);
// Different data types
// Storing different data types inside an array is not recommended because it nwill not make sense in the context of programming
letdetails=["John","Smith",32,true];
console.log(details);
// Objects
// Objects are another special kind o fdata type that's used to mimic real world objects/items.
// It is used to intentionally express the absence of a value in variable declaration/initialization
// Null simply means that a data type was assigned to a variable but it does not hold any value/amount or is nullified
letspouse=null;
console.log(spouse);
// Using null compared to 0 value and an empty string is much better for readability purposes
// Null is also considered as a data type of it's own compared to 0 which is a data type of a number and a single quotes which are a data type of a string.
letmyNumber=0;
console.log(myNumber);
letmyString='';
console.log(myString);
// Undefined
letfullName;
console.log(fullName);
// Undefiend vs Null
// One clear difference between undefined and null is that for undefined, a variable was created but was not provided a value but, null means that a variable was created and was assigned a value that does not hold any value/ amount.
// certain processes in programming would often return a "null" value when certain tasks results to nothing.