" Refactoring is intended to improve the design, structure, and/or implementation of the software, while preserving its functionality."
I don't think you've improved the design, structure, or implementation of this code. You've taken some clear, easy to read code, and made it harder to read. You've decreased the number of lines being used, but what's the benefit of that? We aren't charged by the number of lines we use.
Please, please don't do this.
Man, good job on writing and puttin you out there, but I made an account just to reply on this. Hate to see things overused just because they're shiny.
I noted there was some legacy code that was using loops and wasn't really efficient with the tools we have nowadays.
You replaced one completely fine loop with two loops and a ton of allocations. for is not freaking outdated. I think you meant to say "pretty" or "easier to follow", because the "modern" version is way, way less efficient than the original.
I wish I could do it all at our place too. Unfortunately, most (german) visitors to our site still use Internet Explorer, because of SAP or other requirements from their companies.
I always have to make everything as old as possible so that it works everywhere. These are often customers from the legal field, funnily enough - who then still use Internet Explorer.
Thank you for your post, I find it quite useful, especially to refresh my brain cells a bit.
The article is well written and it has a very good knowledge about how to refactor a code, but I would do this refactoring in a completely different way. If you have a static list of items (that is short enough as in the example), why don't you simple create a variable that will be the final resolve as you expect? Why using loops and so on while you could have a simple
const newOutput = [ ['Angular', 3, '#d17a29'], ['React', 1, '#da9554'], ['Vue', 2, '#e3af7f'], ['Next', 1, '#edcaa9'], ['HTML', 2, '#f6e4d4'], ['Other', 3, '#204e77'] ];