Skip to content

Commit 3408bfd

Browse files
feat: add explicit type converstions ex, fix layout for 13inch
1 parent e104a02 commit 3408bfd

File tree

6 files changed

+62
-4
lines changed

6 files changed

+62
-4
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"title": "Boolean Explicit Type Conversion",
3+
"key": "boolean-explicit-type-conversion",
4+
"description": "Understand the Boolean explicit type conversion",
5+
"difficulty": 3,
6+
"explanation": "The conversion rules for Boolean are: Values that are intuitively “empty”, like 0, an empty string, null, undefined, and NaN, become false. anything else becomes true",
7+
"correctAnswer": "false true true true",
8+
"answers": [
9+
{
10+
"answer": "false false false false"
11+
},
12+
{
13+
"answer": "false false false true"
14+
},
15+
{
16+
"answer": "false false true true"
17+
},
18+
{
19+
"answer": "false true true true"
20+
}
21+
]
22+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// What will console.log from the following code;
2+
3+
console.log(Boolean(null), Boolean(' '), Boolean('0'), Boolean('false'));

data/javascript/index.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
{
1313
"title": "Minus Operator Coercion",
1414
"key": "minus-operator-coercion"
15+
},
16+
{
17+
"title": "Number Explicit Type Conversion",
18+
"key": "number-explicit-type-conversion"
19+
},
20+
{
21+
"title": "Boolean Explicit Type Conversion",
22+
"key": "boolean-explicit-type-conversion"
1523
}
1624
]
1725
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"title": "Number Explicit Type Conversion",
3+
"key": "number-explicit-type-conversion",
4+
"description": "Understand the Number explicit type conversion",
5+
"difficulty": 3,
6+
"explanation": "The Number JavaScript object is a wrapper object allowing you to work with numerical values. In a non-constructor context (i.e., without the new operator), Number can be used to perform a type conversion. If the argument cannot be converted into a number, it returns NaN. NOTE: typof(NaN) is 'number' !!",
7+
"correctAnswer": "5 NaN 'number'",
8+
"answers": [
9+
{
10+
"answer": "5 NaN 'number'"
11+
},
12+
{
13+
"answer": "'5' NaN NaN"
14+
},
15+
{
16+
"answer": "5 NaN 'string'"
17+
},
18+
{
19+
"answer": "5 NaN NaN"
20+
}
21+
]
22+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// What will console.log from the following code;
2+
3+
console.log(Number('5'), Number('undefined'), typeof Number('foo'));

src/js/views/JsExercise.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ const JsExercise = ({ match }) => {
7272
}, [match]);
7373

7474
return (
75-
<Container className="mt-5 mb-3">
75+
<Container className="mt-3 mb-3">
7676
<h2>{data.title}</h2>
7777
<p>{data.description}</p>
7878
<Question question={question} />
7979
<Row>
80-
<Col xs={12} md={6} className="mt-5 mb-3">
80+
<Col xs={12} md={6} className="mt-3 mb-3">
8181
<Form action="">
8282
{data.answers &&
8383
data.answers.map((a, index) => {
@@ -104,7 +104,7 @@ const JsExercise = ({ match }) => {
104104
)}
105105
</Form>
106106
</Col>
107-
<Col xs={12} md={6} className="mt-5 mb-3">
107+
<Col xs={12} md={6} className="mt-3 mb-3">
108108
{result === 'success' && (
109109
<Alert variant="success">Right Answer!</Alert>
110110
)}
@@ -125,7 +125,7 @@ const JsExercise = ({ match }) => {
125125
</Col>
126126
</Row>
127127
{result && (
128-
<Row className="mt-5 mb-3">
128+
<Row className="mt-3 mb-3">
129129
<Col>
130130
<h5>Explanation:</h5>
131131
<p>{data.explanation}</p>

0 commit comments

Comments
 (0)