Skip to content

Commit

Permalink
fix(curriculum): JS variables and data types quiz (freeCodeCamp#58274)
Browse files Browse the repository at this point in the history
  • Loading branch information
moT01 authored Jan 23, 2025
1 parent 9acc877 commit 8ff5362
Showing 1 changed file with 33 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ To pass the quiz, you must correctly answer at least 17 of the 20 questions belo

#### --text--

What is JavaScript?
Which of the following best describes JavaScript?

#### --distractors--

Expand All @@ -33,7 +33,7 @@ A database management system.

#### --answer--

A programming language primarily used for web development.
A programming language used for web development.

### --question--

Expand All @@ -43,19 +43,19 @@ Which of the following is NOT a JavaScript data type?

#### --distractors--

`null`
`Number`

---

`undefined`
`Undefined`

---

`bigInt`
`Object`

#### --answer--

`double`
`Double`

### --question--

Expand All @@ -77,29 +77,29 @@ Which of the following is NOT a valid JavaScript variable declaration?

#### --answer--

`public final Long x;`
`public Int x;`

### --question--

#### --text--

Which of the following is a conventional variable name in JavaScript?
Which of the following is a common naming convention for variables in JavaScript?

#### --distractors--

`my_var`
JavaScript case

---

`my-var`
Lightning case

---

`MyVar`
Giraffe case

#### --answer--

`myVar`
Camel case

### --question--

Expand Down Expand Up @@ -127,28 +127,23 @@ What is the difference between `let` and `const` variable declarations in JavaSc

#### --text--

What would be the outcome of the following code?

```js
let name = "Andy";
name[0] = "M";
```
Why are strings considered immutable in JavaScript?

#### --distractors--

The value of `name` would be `"MAndy"`.
You cannot create strings using variables.

---

The value of `name` would be `"Mndy"`.
Strings can only be created using literals.

---

The value of `name` would still be `"Andy"`.
You can change strings, but only through global variables.

#### --answer--

It would throw an error.
Once a string is created, you cannot change its characters directly.

### --question--

Expand Down Expand Up @@ -186,41 +181,41 @@ console.log(hello);

#### --distractors--

Reassigns `world` to the variable `hello`, and prints it out in the console.
Reassigns `" world"` to the variable `hello`, and prints it out in the console.

---

Prints out the number of characters in `Hello world` in the console.

---

Adds the string `world` to the variable `hello`, and prints it out in the console.
Combines `"Hello"` and `" world"` into a new string and prints it, but the value of `hello` remains `"Hello"`.

#### --answer--

Creates a new string that is made of the values of `hello` and `" world"` combined together, and assigns this new string back to `hello` and then prints it out in the console.
Combines the current value of `hello` with the string `" world"`, reassigns it to `hello`, and prints it to the console.

### --question--

#### --text--

Are semicolons required in JavaScript?
Which JavaScript character is used to mark the end of a statement?

#### --distractors--

Yes. The code won't work without semicolons.
`:`

---

Semicolons are sometimes required in JavaScript.
`,`

---

No. It's recommended not to use semicolons in JavaScript.
`.`

#### --answer--

No, but it is generally recommended to use semicolons consistently to avoid potential issues in code.
`;`

### --question--

Expand Down Expand Up @@ -264,7 +259,7 @@ JavaScript performs type checking before execution, meaning type related errors

#### --answer--

You don't need to declare the data type of a variable before using it. JavaScript infers the type based on the value assigned to the variable.
JavaScript infers the type based on the value assigned to the variable.

### --question--

Expand Down Expand Up @@ -410,7 +405,7 @@ Which of the following is NOT a valid string concatenation method in JavaScript?

---

``console.log(`${string1} ${string2}`);``
`console.log("string1 " + string2);`

---

Expand All @@ -424,7 +419,7 @@ Which of the following is NOT a valid string concatenation method in JavaScript?

#### --text--

Which of the following variable names uses camelCase correctly?
Which of the following variable names uses camel case correctly?

#### --distractors--

Expand All @@ -446,23 +441,23 @@ Which of the following variable names uses camelCase correctly?

#### --text--

Which character JavaScript uses to mark the end of a statement?
Why is it beneficial to use semicolons explicitly even though JavaScript has Automatic Semicolon Insertion?

#### --distractors--

`:`
To increase the execution speed of the code.

---

`,`
To maintain consistency with other programming languages.

---

`.`
To allow for better debugging and error tracing.

#### --answer--

`;`
To improve code readability and reliability.

### --question--

Expand All @@ -485,4 +480,3 @@ Which of the following is NOT a JavaScript data type?
#### --answer--

`Float`

0 comments on commit 8ff5362

Please sign in to comment.