File tree 1 file changed +3
-3
lines changed
1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change 34
34
* case), starts empty, and during the iteration I'll be filling it. If I get to al element that doesn't appears on the
35
35
* map, I added with an starting value of 1 (first occurrence). Otherwise I increments its existing value.
36
36
* - The mapping works like this:
37
- * 1. I always return first the actual item. Then I check if the iten exists on the map. If it does exist I just
37
+ * 1. I always return first the actual item. Then I check if the item exists on the map. If it does exist I just
38
38
* have to return the value and increment it. Otherwise, I use the same trick I used on exercise 10.
39
39
* 2. The trick consists on that I don't wanna to return nothing, as the first occurrences of items shall not have
40
40
* the counter on their string. But I need to modify its value. By doing this[file] = 1 the returning value
41
41
* would be '1'. I don't want this. Because of this I put this sentence in an inner void function so the
42
42
* returning value would be 'undefined'. Why would I do that? I don't want 'undefined' either. Because by
43
- * getting and undefined I could use the OR logical operator to return and empty string. By doing this I
44
- * can modify its value and return nothing.
43
+ * getting and undefined I could use the nullish coalescing operator ?? (logical OR operator || would work
44
+ * too) to return and empty string. By doing this I can modify its value and return nothing.
45
45
*/
46
46
export default function fixFiles ( files ) {
47
47
return files . map ( function ( file ) {
You can’t perform that action at this time.
0 commit comments