-
Notifications
You must be signed in to change notification settings - Fork 1
/
all.txt
55 lines (48 loc) · 848 Bytes
/
all.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
truthy-and-falsy
7 kyu
https://www.codewars.com/kata/truthy-and-falsy/solutions/javascript/me/best_practice
-=##__KATA_EXPORTER__##=-
```
const truthy = [
true,
{},
[],
42,
'codewars',
new Date(),
-42,
3.14,
-3.14,
Infinity,
-Infinity,
-1,
Math.random,
];
const falsy = [
false,
null,
undefined,
0,
NaN,
'',
];
```
-=##__KATA_EXPORTER_SEPARATOR__##=-
find-the-unique-number-1
6 kyu
https://www.codewars.com/kata/find-the-unique-number-1/solutions/javascript/me/best_practice
-=##__KATA_EXPORTER__##=-
```
const findUniq = arr => {
const cache = {};
for (const item of arr) {
cache[item] = (cache[item] || 0) + 1;
}
return +Object.keys(cache).find((key) => cache[key] === 1);
}
```
```
const findUniq = arr => {
return arr.find((item) => arr.indexOf(item) === arr.lastIndexOf(item));
}
```