Get VisualStudio Code from here.
Run these three lines in your terminal.
sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install nodejs
Get NodeJS from here.
Browser | Console | Inspector |
---|---|---|
🔥🦊 | Ctrl + Shift + K | Ctrl + Shift + C |
Chrome | Ctrl + Shift + J | Ctrl + Shift + C |
If are not going to initialize again (use this most of the time)
const four = 4
If you are going to initialize again
let four = 4
if (four == 4) {
console.log("is four")
} else {
console.log("is not four")
}
Regular for loops
for (let i = 0; i < 4; i++) {
console.log(i)
}
While loop
let i = 0
while (i < 4) {
console.log(i)
i++
}
Regular functions
function addFour(n) {
return n + 4
}
New stateless functions
const addFour = (n) => {
return n + 4
}
or
const addFour = n => n + 4
const arr = ["zero", "one", "two", "three", "four"]
then iterate through them
arr.forEach(str => {
console.log(str)
})
or add four to each element
const newArr = arr.map(str => str + 4)
const obj = {
name: "Caleb",
favoriteNumbers: [
2,
4,
42
],
anotherObj: {
nestedProp: "🇨🇦"
}
}
Access the properties with:
const canadaEmoji = obj.anotherObj.nestedProp
or:
const canadaEmoji = obj["anotherObj"]["nestedProp"]