Skip to content

Commit e8d7d60

Browse files
fix(curriculum): Update JavaScript Variables and Data Types Review (freeCodeCamp#58679)
Co-authored-by: Jessica Wilkins <67210629+jdwilkin4@users.noreply.github.com>
1 parent 81dd64c commit e8d7d60

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

curriculum/challenges/english/25-front-end-development/review-javascript-variables-and-data-types/6723be264695fb7e619fe1fa.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ Data types help the program understand the kind of data it's working with, wheth
2121
- **Floating point**: A floating point number is a number with a decimal point. Examples include 3.14, 0.5, and 0.0001.
2222
- **String**: A string is a sequence of characters, or text, enclosed in quotes. `"I like coding"` and `'JavaScript is fun'` are examples of strings.
2323
- **Boolean**: A boolean represents one of two possible values: `true` or `false`. You can use a boolean to represent a condition, such as `isLoggedin = true`.
24-
- **Undefined and Null**: An undefined value is a variable that has been declared but not assigned a value. A null value is an empty value, or a variable that has intentionally been assigned a value of `null`.
24+
- **Undefined and Null**: An `undefined` value is a variable that has been declared but not assigned a value. A `null` value is an empty value, or a variable that has intentionally been assigned a value of `null`.
2525
- **Object**: An object is a collection of key-value pairs. The key is the property name, and the value is the property value.
2626

2727
Here, the `pet` object has three properties or keys: `name`, `age`, and `type`. The values are `Fluffy`, `3`, and `dog`, respectively.
2828

2929
```js
3030
let pet = {
31-
name: 'Fluffy',
31+
name: "Fluffy",
3232
age: 3,
33-
type: 'dog'
33+
type: "dog"
3434
};
3535
```
3636

@@ -39,8 +39,8 @@ let pet = {
3939
In this example below, two symbols are created with the same description, but they are not equal.
4040

4141
```js
42-
const crypticKey1= Symbol('saltNpepper');
43-
const crypticKey2= Symbol('saltNpepper');
42+
const crypticKey1= Symbol("saltNpepper");
43+
const crypticKey2= Symbol("saltNpepper");
4444
console.log(crypticKey1 === crypticKey2); // false
4545
```
4646

@@ -63,21 +63,21 @@ let cityName;
6363
- To assign a value to a variable, you can use the assignment operator `=`.
6464

6565
```js
66-
cityName = 'New York';
66+
cityName = "New York";
6767
```
6868

6969
- Variables declared using `let` can be reassigned a new value.
7070

7171
```js
72-
cityName = 'Los Angeles';
72+
cityName = "Los Angeles";
7373
console.log(cityName); // Los Angeles
7474
```
7575

7676
- Apart from `let`, you can also use `const` to declare a variable. However, a `const` variable cannot be reassigned a new value.
7777

7878
```js
79-
const cityName = 'New York';
80-
cityName = 'Los Angeles'; // TypeError: Assignment to constant variable.
79+
const cityName = "New York";
80+
cityName = "Los Angeles"; // TypeError: Assignment to constant variable.
8181
```
8282

8383
- Variables declared using `const` find uses in declaring constants, that are not allowed to change throughout the code, such as `PI` or `MAX_SIZE`.
@@ -103,35 +103,35 @@ let alsoCorrect = "This is also a string";
103103
- Strings are immutable in JavaScript. This means that once a string is created, you cannot change the characters in the string. However, you can still reassign strings to a new value.
104104

105105
```js
106-
let firstName = 'John';
107-
firstName = 'Jane'; // Reassigning the string to a new value
106+
let firstName = "John";
107+
firstName = "Jane"; // Reassigning the string to a new value
108108
```
109109

110110
## String Concatenation in JavaScript
111111

112112
- Concatenation is the process of joining multiple strings or combining strings with variables that hold text. The `+` operator is one of the simplest and most frequently used methods to concatenate strings.
113113

114114
```js
115-
let studentName = 'Asad';
115+
let studentName = "Asad";
116116
let studentAge = 25;
117-
let studentInfo = studentName + ' is ' + studentAge + ' years old.';
117+
let studentInfo = studentName + " is " + studentAge + " years old.";
118118
console.log(studentInfo); // Asad is 25 years old.
119119
```
120120

121121
- If you need to add or append to an existing string, then you can use the `+=` operator. This is helpful when you want to build upon a string by adding more text to it over time.
122122

123123
```js
124-
let message = 'Welcome to programming, ';
125-
message += 'Asad!';
124+
let message = "Welcome to programming, ";
125+
message += "Asad!";
126126
console.log(message); // Welcome to programming, Asad!
127127
```
128128

129-
- Another way you can concatenate strings is to use the concat method. This method joins two or more strings together.
129+
- Another way you can concatenate strings is to use the `concat()` method. This method joins two or more strings together.
130130

131131
```js
132-
let firstName = 'John';
133-
let lastName = 'Doe';
134-
let fullName = firstName.concat(' ', lastName);
132+
let firstName = "John";
133+
let lastName = "Doe";
134+
let fullName = firstName.concat(" ", lastName);
135135
console.log(fullName); // John Doe
136136
```
137137

@@ -140,7 +140,7 @@ console.log(fullName); // John Doe
140140
- The `console.log()` method is used to log messages to the console. It's a helpful tool for debugging and testing your code.
141141

142142
```js
143-
console.log('Hello, World!');
143+
console.log("Hello, World!");
144144
// Output: Hello, World!
145145
```
146146

@@ -149,7 +149,7 @@ console.log('Hello, World!');
149149
- Semicolons are primarily used to mark the end of a statement. This helps the JavaScript engine understand the separation of individual instructions, which is crucial for correct execution.
150150

151151
```js
152-
let message = 'Hello, World!'; // first statement ends here
152+
let message = "Hello, World!"; // first statement ends here
153153
let number = 42; // second statement starts here
154154
```
155155

@@ -201,7 +201,7 @@ let isLoggedin = true;
201201
console.log(typeof isLoggedin); // boolean
202202
```
203203

204-
- However, there's a well-known quirk in JavaScript when it comes to null. The `typeof` operator returns `object` for null values.
204+
- However, there's a well-known quirk in JavaScript when it comes to `null`. The `typeof` operator returns `object` for `null` values.
205205

206206
```js
207207
let user = null;

0 commit comments

Comments
 (0)