The Stack Overflow podcast is back! Listen to an interview with our new CEO.

New answers tagged

3

In JavaScript/TypeScript it is custom to place the opening braces at the end of the line instead of on a new line by itself. Insert a space between control statements and the opening round brackets. (Also don't put round brackets around the expression of a return statement.) Always use braces even when you only have one line after the statement. Example: ...


2

Inefficient Your code has two major inefficiencies due to poor logic order and design Unneeded sort The sort in isArrayValid will be rather slow and not needed if you write to the oneThroughNine to mark numbers found. Before you mark the number found check if its been marked, if so then the game is invalid. function isArrayValid(array: row): boolean { ...


2

After looking at the implementation, this is not an implementation of global state management. The entire point of things like redux is so you can directly connect components to a global store. In your case, it looks like every instance of StateStore has its own unique data structure, which seems to imply that you are only going to use StateStore once. You ...


3

You should NEVER! add superfluous or unused code. Your code should have the single if statement checking for not equal. const href = element.getAttribute('href'); if (href.indexOf('#') !== 0) { element.setAttribute('target', '_blank'); } or better yet avoid the overly complex referencing via get set attribute, and not using a search to ...


1

The main attractions of a bitboard are, to put it shortly: Use the bit-parallel nature of bitwise operations to replace some simple loops. Use the power of arithmetic operations to replace non-trivial algorithms (eg o^(o-2r)). If a bitboard is emulated with a binary string, neither of those is realized. Effectively what you're dealing with then is a ...


Top 50 recent answers are included