Day 1
Lesson 1
console is an object, a collection of data and actions .log() function that can print // for single line comments /* words inside this are ignored */ - for documentation purposes → All data types have access to specific properties such as length for the number of characters in a string console.log(’hotdog’.length) = 6 Operators works on numbers and also to strings just like python, basically concatenation adding string to another string dot operators, accesses the functions/methods innate for that data typecon opening and closing parentheses e.g → ‘example string’.methodName() Basic examples for string trim() → removes whitespace Built-in objects (libraries for python) Math.random() → gives random number 0 to 1 (decimal), can be multiplied to any whole number Math.floor() → rounds the number to nearest whole number Math.ceil() → gives nearest integer
DAY 2
Variables
variables in JS cannot start with numbers follow camel casing, small letter for first word e.g. var favoriteFood = ‘pizza’ can be declared without values and be defaulted to contain ‘undefined’ console.log(meal) \\outputs undefined console.log(meal) \\outputs hotdog
Variable kinds
let - means can be assigned/re-assigned with different values const - cannot be reassigned with a new value
Mathematical Operators with Variables
Basic calculate plus assign commands works +=, -=, /=, *= → can be used using javascript and for let variables Increment and Decrement operators a++; or b—; works and will deduct or add 1 value to variables String manipulation with variables
let favoriteAnimal = 'Dog'; console.log('My favorite animal: '+ favoriteAnimal); let myCity = 'Caloocan City'; console.log( `My name is ${myName}. My favorite city is ${myCity}`); the key is to use caret to indicate that the thing to be printed is a template.
typeOF Operator
the equivalent of type() in python let newVariable = 'Playing around with typeof.'; console.log(typeof newVariable);
Kelvin Weather Project ✅
Dog Years Project ✅
JS Versions: ES6 and Before