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 ...
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 ...
  • 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: ...
  • 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 ...
  • 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: <...
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 ...
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. ...
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 ...
  • 11.9k
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 ...
  • 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 ...
  • 3,426
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 ...
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 ...
12 votes
Accepted

Selecting a prize category based on two parameters

To make @kfx's answer more readable: ...
  • 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 ...
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 ...
  • 578
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 ...
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&...
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 ...
  • 25.1k
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 ...
  • 20.6k
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 ...
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(): ...
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: ...
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 ...
8 votes
Accepted

Chart showing the Percentage of Answered CR questions

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 ...
  • 7,916
8 votes
Accepted

Reverse Integer

The question states that the input is a number 32 signed int so checking for undefined or null is a waste of time. The solution ...
  • 20.6k
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 ...
  • 54.1k
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 ...
8 votes
Accepted

MMMRjs a product of BYTES Genesis

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

Vue.js search functionality

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

Counting words from stored .md files

Another suggestion: with TypeScript, you only need to note the type of a parameter when TypeScript can't infer it itself. You might find it easier to read and write code when you avoid explicitly ...

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