# Automatic detection of wrong index typos

**URL:** <https://es.discourse.group/t/automatic-detection-of-wrong-index-typos/2334>\
**Category:** 💡 Ideas\
**Created:** [March 31, 2025, 1:55pm UTC](https://es.discourse.group/t/automatic-detection-of-wrong-index-typos/2334 "2025-03-31T13:55:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaroslav.tavgen](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/jaroslav.tavgen/32/2732_2.png) [@jaroslav.tavgen](https://es.discourse.group/u/jaroslav.tavgen)\
**Post date:** [March 31, 2025, 1:55pm UTC](https://es.discourse.group/t/automatic-detection-of-wrong-index-typos/2334/1 "2025-03-31T13:55:28Z")

</div>

```javascript
let numbers = Array.from({length:100}, (_,i)=>i);
for ( let i = 0; i < 10; i++ ) {
  for (let j=0;j < 20; j++ ) {
    let number = numbers [i];
  }
}

```

This is the place where the compiler, interpreter or IDE could publish an error or a warning.

This is a clear situaion when a programmer wanted to use the key "j" but instead made a typo and used the key "i". Had he wanted to use the "i" key he would have initiated the variable "number" inside the first loop, not the second one.

In my opinion, future IDEs, compilers and interpreters could fixate such obvious errors and point them out to a programmer. Those bugs are often pretty hard to find.

---

<div class="post-metadata">

**Author:** ![theScottyJam](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/thescottyjam/32/616_2.png) [@theScottyJam](https://es.discourse.group/u/theScottyJam)\
**Post date:** [March 31, 2025, 5:45pm UTC](https://es.discourse.group/t/automatic-detection-of-wrong-index-typos/2334/2 "2025-03-31T17:45:11Z")

</div>

What exactly makes it clear that the "j" variable was intended? The best thing I can think of is the fact that "j" is currently unused. You can configure a linter that automatically notifies you if you have unused variables. I'm personally not a fan of that kind of warning (too many false positives), but I see the value in it.
