// run: in browser or node console.log("hello world!"); // node index.js // run in node
// variable // use let to declare a variable let name //undefined name = "Chandler"; console.log(name);
// constants, don't need to assign const interestRate = 0.3; // interestRate = 1; console.log(interestRate);
// primitive/value types * 6 // string, number, boolean, undefined, null, symbol. primitive types don't have properties and methods, only object types do. let firstName = "Monica"; let age = 30; // don't have float numbers or integers, all are number type let isApproved = true; let lastName; // undefined let middleName = null; // type: object
// dynamic typing // type of variable can be changed.
// functions // function is a set of statements that either performs a task or calculate and returns a value. functiongreet(firstName,lastName){ // name: parameter console.log('Hello ' + firstName + ' ' + lastName);
} // do not need to terminate with ; greet('Joey'); // argument greet('Chandler','Bing');
// calculating a value functionsquare(number){ return number*number; } let number = square(2); console.log(number);