Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP2universalStack: javascript
arraysreadabilitymap-joinsimplification
Build a delimited id list with map().join() not a manual loop
Replace an index-based for loop that concatenates ids with a separator by mapping then joining for clearer, less error-prone code.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | for (let i = 0; i < articles.length; i++) { |
| 2 | idList += articles[i].id; |
| 3 | if (i < articles.length - 1) idList += ','; |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const idList = articles.map(a => a.id).join(','); |
Explanation (EN)
Objašnjenje (HR)