Skip to content

Commit ed4878f

Browse files
committed
minor
1 parent 7e5ffe2 commit ed4878f

File tree

2 files changed

+10
-8
lines changed
  • 1-js/02-first-steps/06-type-conversions/1-primitive-conversions-questions

2 files changed

+10
-8
lines changed

1-js/02-first-steps/06-type-conversions/1-primitive-conversions-questions/solution.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ true + false = 1
1010
"4" - 2 = 2
1111
"4px" - 2 = NaN
1212
7 / 0 = Infinity
13-
" -9\n" + 5 = " -9\n5"
14-
" -9\n" - 5 = -14
15-
null + 1 = 1 // (3)
16-
undefined + 1 = NaN // (4)
13+
" -9 " + 5 = " -9 5" // (3)
14+
" -9 " - 5 = -14 // (4)
15+
null + 1 = 1 // (5)
16+
undefined + 1 = NaN // (6)
1717
```
1818

1919
1. The addition with a string `"" + 1` converts `1` to a string: `"" + 1 = "1"`, and then we have `"1" + 0`, the same rule is applied.
2020
2. The subtraction `-` (like most math operations) only works with numbers, it converts an empty string `""` to `0`.
21-
3. `null` becomes `0` after the numeric conversion.
22-
4. `undefined` becomes `NaN` after the numeric conversion.
21+
3. The addition with a string appends the number `5` to the string.
22+
4. The subtraction always converts to numbers, so it makes `" -9 "` a number `-9` (ignoring spaces around it).
23+
5. `null` becomes `0` after the numeric conversion.
24+
6. `undefined` becomes `NaN` after the numeric conversion.

1-js/02-first-steps/06-type-conversions/1-primitive-conversions-questions/task.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ true + false
1717
"4" - 2
1818
"4px" - 2
1919
7 / 0
20-
" -9\n" + 5
21-
" -9\n" - 5
20+
" -9 " + 5
21+
" -9 " - 5
2222
null + 1
2323
undefined + 1
2424
```

0 commit comments

Comments
 (0)