mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-27 02:01:02 -04:00
fix(curriculum): JS variables and data types quiz (#58274)
This commit is contained in:
@@ -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--
|
||||
|
||||
@@ -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--
|
||||
|
||||
@@ -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--
|
||||
|
||||
@@ -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--
|
||||
|
||||
@@ -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--
|
||||
|
||||
@@ -186,7 +181,7 @@ 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.
|
||||
|
||||
---
|
||||
|
||||
@@ -194,33 +189,33 @@ 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--
|
||||
|
||||
@@ -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--
|
||||
|
||||
@@ -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);`
|
||||
|
||||
---
|
||||
|
||||
@@ -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--
|
||||
|
||||
@@ -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--
|
||||
|
||||
@@ -485,4 +480,3 @@ Which of the following is NOT a JavaScript data type?
|
||||
#### --answer--
|
||||
|
||||
`Float`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user