54 votes
Accepted

You hate h̶a̶t̶s̶ reputation? Click here to get rid of it

It would be better to do this with a user style, e.g. using the Stylus extension, like this: .rep, .reputation, .reputation-score { visibility: hidden; } One ...
user avatar
39 votes
Accepted

Count all vowels in string

An alternative route is to use string.replace() and Regular Expressions to strip everything but the vowels from the string. Then count the length of the resulting ...
user avatar
  • 24.8k
33 votes

Using fetch() and a new Promise object to get API results

A few comments: 1) fetch already returns a promise, which means this: ...
user avatar
  • 2,525
29 votes

You hate h̶a̶t̶s̶ reputation? Click here to get rid of it

You could use querySelectorAll instead of getElementsByClassName. That way, you have a bit more flexibility in targeting ...
user avatar
  • 24.8k
28 votes

Count all vowels in string

I'm just wondering if there's an easier way to solve this problem without the big blocky code in the if statement. Well, you could put all of those in an array: <...
user avatar
24 votes
Accepted

Check if images are loaded (ES6 Promises)

Well, you normally don't want to use the Promise constructor in your higher level code, you want to Promisify as low as possible. So let's create a function that ...
user avatar
21 votes

Setting flags to show three buttons

You could take an object and check if the action exists. If so, take the value as key for assignment. ...
user avatar
16 votes

You hate h̶a̶t̶s̶ reputation? Click here to get rid of it

Update url UserScripts have the magical ability to update themselves if you provide a link to a raw version of your script as a UserScript header: Note: You actually have to increase the version, or ...
user avatar
  • 11.8k
15 votes
Accepted

Convert minutes portion of time to decimal

Use const instead of let to declare variables if the value doesn't change. You are executing ...
user avatar
  • 10.3k
14 votes
Accepted

Array duplicate removal for duplicates exceeding `N`-number

As you expected, there is a much simpler way to do this. Create a map where the keys are the numbers in the array and the value is the number of times each number appears in the array. Filter the ...
user avatar
  • 3,416
13 votes
Accepted

JavaScript/ECMAscript 6 classes organization

Most interesting, In BaseObject, you should really have a constructor that builds this.listeners, it would make your code much ...
user avatar
  • 32.4k
13 votes

Stack Exchange rev​iew queue notifications

I don't see much benefit to the enum. The Notification.permission string (or the return value of requestPermission()) is already ...
user avatar
13 votes

Vue.js search functionality

One improvement would be factoring out the repeated call to this.search.toLowerCase() and storing the result in a block-scoped constant so it: doesn't need to be ...
user avatar
12 votes
Accepted

Selecting a prize category based on two parameters

To make @kfx's answer more readable: ...
user avatar
  • 1,530
12 votes
Accepted

Reformatting a date from YYYY-MM-DD to MM/DD/YYYY

Simpler approach Another option is to construct a Date object (this can be achieved by appending a time at midnight to the date) and pass that to ...
user avatar
12 votes
Accepted

Using async / await with dynamic import() for ES6 modules

Approach 2 does not work because accoring to MDN: import '/modules/my-module.js'; Is how you import a module for Import a ...
user avatar
  • 568
10 votes
Accepted

If non-array property exists convert it to one and push new value

Basically after reading over the code, I interpret that the conditional (i.e. !obj[key].push) checks if the value at the given ...
user avatar
10 votes
Accepted

Draw sine wave going around a circle

Overall you have a good D3 code here, congrats (I'm fairly impressed with the questions I've seen here at CR lately, from people claiming "This is the very first time I've used d3 or drawn a SVG&...
user avatar
10 votes
Accepted

Restructuring JSON to create a new JSON where properties are grouped according to similar values

Scoping issues You are using an "immediately invoked function expression" (IIFE) here to scope the unique_dates, but in the process you forgot to use the ...
user avatar
  • 25k
9 votes

Count all vowels in string

Sᴀᴍ Onᴇᴌᴀ answer has the right idea for small strings, but can be improved by using a Set to hold the vowels rather than an array. This reduces the overhead of ...
user avatar
  • 19.9k
9 votes
Accepted

Vue.js search functionality

It is really hard to say, but at least for me, your code is fine. It seems readable and has no issues. Perhaps if you want to change the style and make it more "canonical", you could write ...
user avatar
9 votes

Counting words from stored .md files

How to modify this code, so it doesn't use forEach? One way to achieve this is using Array.prototype.reduce(): ...
user avatar
9 votes
Accepted

Error solution: Uncaught TypeError

Does this open up the possibility for any buggy behavior that I don't know about? It's not likely to. The if statement is fine, though it can be made cleaner: ...
user avatar
8 votes

JavaScript/ECMAscript 6 classes organization

So, going to 'answer' my own question here with a nice thing I discovered since then. Might expand my answer if I discover more stuff. In ECMAscript 6 rather than ...
user avatar
8 votes
Accepted

Vue - It's the Royal Game of Ur

warning: cheesy meme with bad pun below - if you don't like those, then please skip it... Question responses Do I have too many / too few components? I am aiming to make several other games in Vue ...
user avatar
8 votes
Accepted

Chart of Percentage questions Answered

When I ran your script and started digging through the dom, I noticed that Apr 21 12:00 AM was missing -- I wonder why that was. Anyhow, I wanted to encourage ...
user avatar
  • 7,596
8 votes

Find all letter Combinations of a Phone Number

whenever you encounter a task where you have to combine or permute things, then backtracking is a possible approach. True. It is not necessarily the best though (in fact it is rarely the best). In ...
user avatar
  • 53k
8 votes

Expanding powers of expressions of the form ax+b

You don't need the special case for k == 0. When k == 0, the result of the other expression will be 1 as well. For this ...
user avatar
  • 20.9k
8 votes
Accepted

MMMRjs a product of BYTES Genesis

Comments The comments such a This is Mean. are pointless. And the comment ...
user avatar
  • 10.3k
8 votes

Vue.js search functionality

Another way is to create an array from name and category and combine some method with ...
user avatar
  • 553

Only top scored, non community-wiki answers of a minimum length are eligible