Last active
October 19, 2017 10:47
-
-
Save zkwsk/30c0fe7d3389b87893317eeefa8ef94f to your computer and use it in GitHub Desktop.
HYF JS-1 Session 2 - recap from last time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Single line comment 1 + 1 | |
/* | |
This is a multiline | |
comment | |
*/ | |
// Data types | |
/* | |
Number - (Integer) | |
Boolean (true/false) | |
String "some text" | |
Array | |
Objects | |
*/ | |
let string1 = "First string"; | |
let string2 = "Second string"; | |
let string3 = "third string"; | |
// let variable = "Hello " + | |
// string1 + | |
// " " + | |
// string2 + | |
// " " + | |
// "how are you doing" + | |
// " " + | |
// string3; | |
//let variable = "Hello" + " " + string1; | |
//let variable = `${string1} ${string2} how are you doing ${string3}`; | |
let name = "Zaki"; | |
let gender = "Mr." | |
let weather = "-5"; | |
let variableEnglish = `Hello ${gender} ${name} how are you doing today. It's ${weather} degrees outside.`; | |
let variableDanish = `Hej ${gender} ${name} hvordan går det idag. Det er ${weather} grader udenfor.`; | |
// console.log(variableEnglish); | |
// console.log(variableDanish); | |
/* | |
Variables: | |
Var | |
Let | |
Constant | |
*/ | |
let hungry = false; | |
// Two hours later | |
// hungry = true; | |
// hungry = false; | |
// console.log(`Is Zaki hungry? ${hungry}`); | |
// Arrays have specific order! | |
// let pizzaIngredients = ["cheese", "salami", "tomatoes"]; | |
// console.log(pizzaIngredients); | |
// console.log(pizzaIngredients[1]); | |
// Objects cannot be guaranteed to have specific order. | |
let pizzaObject = { firstIngredient: "cheese", secondIngredient: "salami" } | |
console.log(pizzaObject); | |
// Operators | |
// Assignment | |
let text = "some text" // We assign from right to left | |
// Comparison | |
text === "some other text" // "Is 'some other text' equal to 'some text'?". Answer: false | |
text !== "some other text" // "Is 'some other text' NOT equal to 'some text'?". Answer: true | |
let number = 3; | |
number > 2; // "Is number greater than 2. Answer: true | |
number < 2; // "Is number less than 2. Answer: false | |
// Concatenation | |
"some string" + "some other string"; | |
// Math | |
1 + 2 // 3 | |
1 / 3 // .333333 | |
2 * 3 // 6 | |
3 + number // 6 | |
// Modulus - returns the remainder | |
6 / 3 // 2 | |
6 % 3 // 0 | |
7 % 3 // 1 | |
console.log(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment