- Understand and use JavaScript variables.
- Work with basic data types and operators.
- Documentation is crucial for:
- Understanding code.
- Using code.
- Debugging.
- Collaborating with peers.
- Use the Code Nation Coding Guides to refer to class syntax.
- Remember: Googling is part of a developer's job! Platforms like W3Schools and egghead.io can be invaluable.
- JavaScript enables dynamic behaviors on a webpage.
- Variable is a container that holds data.
let box; box = 8;
- Cannot start with a number.
- Cannot be keywords.
let mySpiritAnimal = "unicorn"; // Valid let thisIsAcceptable = "acceptable"; // Valid
-
We can declare and assign a value to a variable in two steps or in one step.
let cake; cake = "lemon"; // OR let cake = "lemon";
-
Variables can be reassigned.
let myBox = 8; myBox = 56; // myBox is now 56
-
Numbers: Can be positive/negative and may have decimals.
let num = 1234; let decimalNum = 1.99;
-
Strings: Textual data enclosed in quotes.
let greeting = "Hello, World!"; let codeString = "code123";
-
Basic operators include:
+
,-
,*
,/
.let num1 = 10, num2 = 5; let sum = num1 + num2; // 15
-
Strings can also be concatenated using the
+
operator.let str1 = "Hello, "; let str2 = "World!"; console.log(str1 + str2); // Hello, World!
-
Mixing data types can produce unexpected results.
console.log(5 + "cat"); // 5cat
This lesson covered the importance of documentation, declaring variables in JavaScript, the basic data types, and how to perform operations on them. Always remember to refer to documentation when in doubt.
Keep practicing and happy coding!