New answers tagged

0 votes
Accepted

Function that querys database and then renders a view

Test for invalid state up front Eliminating branching simplifies. The high level reads in a more consistant general abstraction level. ...
  • 6,625
0 votes

Coderbyte: String Reduction

I know this is very old, but I have a small update to this program, I believe you do not need the while loop and original because it always executes once or goes in indefinite loop if the string has ...
0 votes

Responsive Navigation with hamburger menu

Review The code seems a bit over-complicated. There are multiple DOM lookups for the same elements (e.g. using document.getElementById(), ...
3 votes
Accepted

Pick two random cards from a standard deck

There is a bug A return statement is missing when making the recursive call when the same card is picked twice. Don't use recursion to repeat an operation To repeat ...
  • 110k
1 vote

Re-order table columns in HTML dynamically with Javascript

Start with the data in Javascript. Always sort the Javascript, never from the html table. Always create a new table. Throwing away the pre-existing table fantastically simplifies everything. I ...
  • 6,625
2 votes
Accepted

SetTimeout to populate Javascript Object while a function looped AJAX requests to get data

Initial Review thoughts Before addressing the main question I’d like to address a few points first. Variable declaration style It is nice that seriesData is ...
0 votes

Basic quiz game - HTML, JAVASCRIPT. How is this approach?

[is] this approach is correct ... for a basic quiz game. No. A quiz game's nature is that it will change. This is hard coded through and through such that each fresh quiz will effectively be its own ...
  • 6,625
0 votes

Calculate sum of values from checkboxes

Your code is pretty small, and pretty easy to follow. You seem to have tried to make everything concise and avoid really long lines that go on forever and ever and ever and ever and ever and ever and ...
5 votes
Accepted

Extracting records of type "withdraw_rewards" from a multi-level data structure

The pipeline can be written simpler: replacing nested .forEach using .flatMap replacing conditionals inside ...
  • 110k
0 votes

Extracting records of type "withdraw_rewards" from a multi-level data structure

here is example if you want to use flatmap ...
5 votes
Accepted

Calculate sum of values from checkboxes

Your code is too complex. General points Use textContent when setting text in an HTMLElement rather than ...
  • 20.6k
1 vote

Directive to randomly show/hide elements

Correct me if this is incorrect but it appears that this code utilizes jQuery methods like .children(), .attr(), ...
3 votes

Get all partitions of an array into k non-empty sub-arrays

Time and space complexity To calculate the time and space complexity, it's useful to consider the output: what must it contain. For every way to split into sub-arrays, the output will contain one ...
  • 110k
0 votes

JS "Tabs" element

I don't think the two loops of tabButtons.forEach is avoidable because these are executed at different times and both are necessary. The first is assigning a click ...
  • 181
1 vote
Accepted

error tracking in api endpoint

Understanding the Fetch API The MDN documentation on using the Fetch API answers most of your questions, it's nicely written with many example use cases, I recommend to read it well from top to bottom....
  • 110k
2 votes
Accepted

Create a Grid From User Input and Change Square Color on Mouse Over - The Odin Project: Etch-a-Sketch

Use prettier and eslint Code auto-formatters are awesome. Try one at https://prettier.io/playground and look into adding it to your build which will make your code easier for other developers to read. ...
  • 2,983
3 votes
Accepted

Card generator with some calculations

Review Your code is way too complex The Card object is not a card, rather it is a utility function to copy a template. There is no need for it or you could have ...
  • 20.6k
3 votes

Card generator with some calculations

Split the loop The forEach loop in generateCard does two very different things: If the current object is not the result, then ...
  • 110k

Top 50 recent answers are included