I'm trying to solve a coding problem and it seems my thinking process is wrong in this problem. I'm trying to solve the following:

```js
/*
        Given a string and a number n, replace every nth character with '_'.
        "foreigner", 2 => "f_r_i_n_r"
        "leetcode", 3 => "le_tc_de"
        "leetcode", 1 => "________"
        */
function replaceChar(string1, number) {
  let stringArr = string1.split("")
  for (let i = 0; i < stringArr.length; i++) {
    if (i === i + 1) {
      stringArr[i] = "_"
    }
  }
  stringArr.join('')
  console.log(stringArr)
}
replaceChar("foreigner", 2);
```

The function at bottom is written by me and it seems it's not working as I intended.