Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f3a975d

Browse files
committed
Fix typo Q 80
1 parent 2b45e6f commit f3a975d

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed

‎README.md‎

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3240,7 +3240,6 @@ If you know how a traditional method works in JavaScript, then the code challeng
32403240
const result = ["ronaldo", "messi", "neymar", "Ronaldo", "LuKaKUUUU"].sort();
32413241

32423242
console.log(result);
3243-
32443243
```
32453244
32463245
- A: ["LuKaKUUUU", "Ronaldo", "messi", "neymar", "ronaldo"]
@@ -3251,21 +3250,21 @@ console.log(result);
32513250
<details><summary><b>Answer</b></summary>
32523251
<p>
32533252
3254-
In JavaScript, the built-in `sort()` method sorts the elements of an array. It returns a sorted array in ascending order. Note that each element will be converted to strings and then compared according to the sequences of UTF-16 code unit values. What does it mean?
3253+
In JavaScript, the built-in `sort()` method sorts the elements of an array. It returns a sorted array in ascending order. Note that each element will be converted to strings and then compared according to the sequences of UTF-16 code unit values. What does it mean?
32553254
32563255
It means, "banana" < "cherry" or 80 < 9 (because "80" < "9" in the Unicode order).
32573256
32583257
If you run the following code `const result = [9, 11, 89].sort();`, the constant `result` will be sorted as `[11, 8, 9]` rather than `[9, 11, 89]` because the engine will convert the number value to string.
32593258
32603259
The following codes might give you a hint about the relationship between character and number. Ultimately, as the computer can only understand 0 and 1, all characters and even decimal numbers are then converted to 1 and 0. `charCodeAt()` gives us the decimal value of any string evaluated.
32613260
3262-
`console.log("LuKaKUUUU".charCodeAt(0))` or `console.log("LuKaKUUUU".charCodeAt())` ==> 76
3263-
`console.log("Ronaldo".charCodeAt(0))` or `console.log("Ronaldo".charCodeAt())` ==> 82
3264-
`console.log("messi".charCodeAt(0))` or `console.log("messi".charCodeAt())` ==> 109
3265-
`console.log("neymar".charCodeAt(0))` or `console.log("neymar".charCodeAt())` ==> 110
3266-
`console.log("ronaldo".charCodeAt(0))` or `console.log("ronaldo".charCodeAt())` ==> 114
3267-
`console.log("9".charCodeAt())` or `console.log("99".charCodeAt())` ==> 57
3268-
`console.log("80".charCodeAt())` or `console.log("8".charCodeAt())` ==> 56
3261+
`console.log("LuKaKUUUU".charCodeAt(0))` or `console.log("LuKaKUUUU".charCodeAt())` ==> 76
3262+
`console.log("Ronaldo".charCodeAt(0))` or `console.log("Ronaldo".charCodeAt())` ==> 82
3263+
`console.log("messi".charCodeAt(0))` or `console.log("messi".charCodeAt())` ==> 109
3264+
`console.log("neymar".charCodeAt(0))` or `console.log("neymar".charCodeAt())` ==> 110
3265+
`console.log("ronaldo".charCodeAt(0))` or `console.log("ronaldo".charCodeAt())` ==> 114
3266+
`console.log("9".charCodeAt())` or `console.log("99".charCodeAt())` ==> 57
3267+
`console.log("80".charCodeAt())` or `console.log("8".charCodeAt())` ==> 56
32693268
32703269
Noted that if index is not a number, it defaults to 0. The answer is A.
32713270
@@ -3277,35 +3276,34 @@ Noted that if index is not a number, it defaults to 0. The answer is A.
32773276
###### 80. What's the output?
32783277
32793278
```javascript
3280-
3281-
const anArray = typeof [];
3282-
const aTypeOfNull = typeof null;
3279+
const anArray = typeof [];
3280+
const aTypeOfNull = typeof null;
32833281

32843282
const weirdFirst = null instanceof Object;
32853283
const weirdSecond = [] instanceof Object;
32863284
const weirdThird = [] instanceof Array;
32873285

3288-
console.log(anArray)
3289-
console.log(aTypeOfNull)
3290-
3291-
console.log(weirdFirst)
3292-
console.log(weirdSecond)
3293-
console.log(weirdThird)
3286+
console.log(anArray);
3287+
console.log(aTypeOfNull);
32943288

3289+
console.log(weirdFirst);
3290+
console.log(weirdSecond);
3291+
console.log(weirdThird);
32953292
```
3296-
- A: "array" - "null" - false - true - true
3297-
- B: "array" - "object" - false - true - true
3298-
- C: "object" - "object" - false - false - true
3299-
- D: "object" - "object" - false - true - true
3293+
3294+
- A: "array" - "null" - false - true - true
3295+
- B: "array" - "object" - false - true - true
3296+
- C: "object" - "object" - false - false - true
3297+
- D: "object" - "object" - false - true - true
33003298
33013299
<details><summary><b>Answer</b></summary>
33023300
<p>
33033301
3304-
In the 80th challenge question, we will review some fundamental "issue" or "weird" features in JavaScript relating to the `typeof` and `instance` operators. Given that the original version of the JavaScript language was designed in just 10 days, there are a bundle of inconsistent behaviors that cannot be fixed. They are pamernal features existing in the modern language. If we fix it, a lot of websites might crash.
3302+
In the 80th challenge question, we will review some fundamental "issue" or "weird" features in JavaScript relating to the `typeof` and `instance` operators. Given that the original version of the JavaScript language was designed in just 10 days, there are a bundle of inconsistent behaviors that cannot be fixed. They are permanent features existing in the modern language. If we fix it, a lot of websites might crash.
33053303
33063304
The above code shows us some of the weird features in JavaScript. For example, `[]` is an array but the `typeof []` gives us `object`. Note that you might take advantage of `Array.isArray([])` rather than `typeof` to examine whether a variable is an array or not.
33073305
3308-
`typeof null;` is another weird operator as it returns `object`. However `null instanceof Object;` returns `false`. What~The~Hell!!!
3306+
`typeof null;` is another weird operator as it returns `object`. However `null instanceof Object;` returns `false`. ~WhatTheHell~!!!
33093307
33103308
Man, `[] instanceof Object;` and `[] instanceof Array;` both return `true`. How inconsistent it is.
33113309
@@ -3315,4 +3313,3 @@ The answer is D.
33153313
33163314
</p>
33173315
</details>
3318-

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /