mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
feat(curriculum): Create a JavaScript Math Objects and Operators Quiz (#56539)
Co-authored-by: Naomi <accounts+github@nhcarrigan.com> Co-authored-by: Ilenia <26656284+ilenia-magoni@users.noreply.github.com> Co-authored-by: Krzysztof G. <60067306+gikf@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
5b7521d697
commit
0ab1ff43a6
+136
-100
@@ -17,439 +17,475 @@ Answer all of the questions below correctly to pass the quiz.
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What is the result of this code?
|
||||
|
||||
``` js
|
||||
const num1 = Number('888');
|
||||
const num2 = new Number('777');
|
||||
|
||||
console.log(num1 === 888);
|
||||
console.log(num2 === 777);
|
||||
```
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
```js
|
||||
true
|
||||
true
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
```js
|
||||
false
|
||||
false
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
```js
|
||||
false
|
||||
true
|
||||
```
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
```js
|
||||
true
|
||||
false
|
||||
```
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which of the following is not an arithmetic operator in JavaScript?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`%`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`+`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`--`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`==`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which of the following will log the correct gross profit?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
``` js
|
||||
let store1_sales = 7500;
|
||||
let store2_sales = 6000;
|
||||
console.log("Total Sales: " + store1_sales + store2_sales);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
``` js
|
||||
let store1_sales = 7500;
|
||||
let store2_sales = 6000;
|
||||
console.log("Total Sales: " + store1_sales - store2_sales);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
``` js
|
||||
let store1_sales = 7500;
|
||||
let store2_sales = 6000;
|
||||
console.log("Total Sales: " + (store1_sales - store2_sales));
|
||||
```
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
``` js
|
||||
let store1_sales = 7500;
|
||||
let store2_sales = 6000;
|
||||
console.log("Total Sales: " + (store1_sales + store2_sales));
|
||||
```
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What is the result of the statement `25 * 4 - 16 / (2 * 4) + 8`?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`18.5`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`107.5`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`17`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`106`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which operator should you use when decrementing a variable in JavaScript?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`++`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`//`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`**`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`--`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which of the following is not a bitwise operator?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`&`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`|`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`^`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`>`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which of the following is the correct compound operator for getting the remainder?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`//=`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`\=`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`%%=`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`%=`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What is the difference between the `==` and `===` operators?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
There is no difference. The comparison result will always have the same result.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
The `==` operator is used to check if the data type is the same while the `===` is used to check if the value is equal.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
The `==` operator can only be used with primitive types while the `===` operator is only used for objects.
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
The `==` operator only compares values whereas the `===` operator compares values and types.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which of the following statements are false about unary plus (`+`) operators?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
It tries to convert the operand into a number.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
It is the fastest way to convert an operand to a number.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
It can convert operands with negative numbers except for hexadecimals.
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
It can't convert `true`, `false`, or `null` into a number.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which method in the built-in Math object is used to round up a number?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`Math.round(num)`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`Math.floor(num)`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`Math.fround(num)`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`Math.ceil(num)`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which of the following Math object methods are used to raise a base to a power?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`Math.exp(base, power)`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`Math.raise(base, power)`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`Math.e(base, power)`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`Math.pow(base, power)`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which of the following is the correct method for generating a random number in JavaScript?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`Math.rand(1,10)`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`Math.rand()`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`Math.random(1,10)`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`Math.random()`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which of the following will return `false`?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`isNaN("1998", "1999")`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`isNaN({})`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`isNaN(undefined)`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`isNaN(null)`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which of the following will convert `172` to its hexadecimal equivalent?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`(-0xa5).toString(2);`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`(172).string(0x);`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`(172).parseString(0x);`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`(172).toString(16);`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which of the following is the right way to convert a string to an integer?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`parseINT("300")`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`int("300")`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`integer("300")`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`parseInt("300")`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which of the following statements is false?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`parseFloat()` ignores trailing invalid characters
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`parseFloat()` can parse a string that begins with `Infinity` or `-Infinity`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`parseFloat("0x1f")` will return `0`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`parseFloat()` requires two parameters
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which of the following is false?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
A number greater than 100 as an argument to the `Number.prototype.toFixed()` method will result to a range error
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`Number.prototype.toFixed(numDecimalPlaces)` is used to return a number converted to a string with decimals places depending on the argument
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
Calling the `Number.prototype.toFixed()` method on a number object with decimal points and no argument will round the number to the nearest ones
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
Using `Number.prototype.toFixed()` without an argument will by default add a decimal point followed by a zero
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which of the following is not a comparison operator?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`!=`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`>=`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`===`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`!>`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which of the following is false?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
Exponentiation has a lower operator precedence than the grouping operator `()`.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
Postfix operators like `x++` or `x--` has higher precedence than prefix operators.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
Relational operators like `>` or `<` has higher precedence than equality operators.
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
Logical operator like `AND` and `OR` have higher precedence than bitwise operators.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
`Math.random()` returns a number in what range?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`Math.random()` returns a number between 0 (inclusive) and 1 (inclusive)
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`Math.random()` returns a number between 0 (exclusive) and 1 (inclusive)
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`Math.random()` returns a number between 0 (exclusive) and 1 (exclusive)
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`Math.random()`returns a number between 0 (inclusive) and 1 (exclusive)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user