Question: I'm working with the problem below:

You are provided with an empty array called nestedArr. Using a for loop starting at index 0, add 5 subarrays to nestedArr, with each nested array containing the string 'loop' concatenated with the corresponding index in nestedArr as its first element, and the index as its second element.

Example of a subarray: ['loop3', 3].

This is what I've tried

```
const nestedArr = [];
for (var i = 0; i < 5; i++) {
  nestedArr[i] = []
  for(var j = 0; j < 2; j++) {
    nestedArr[i][j] = 'loop'+[i], i
  }
}

console.log(nestedArr)

```

It gives me [['loop0', 'loop0'], ['loop1', 'loop1'], ['loop2', 'loop2'], ['loop3', 'loop3'], ['loop4', 'loop4']]

Can't figure out how to have it in this format: ['loop3', 3].

Please guide me!

Answer: 
You can just construct the array literally or use a ternary operator to check the first index in the inner loop and concatenate the string `loop`

```js
const nestedArr = [];
for (var i = 0; i < 5; i++) {
  nestedArr[i] = ['loop' + i, i];
}

const nestedArr2 = [];
for (var i = 0; i < 5; i++) {
  nestedArr2[i] = [];

  for(let j = 0; j < 2; j++){
      nestedArr2[i][j] = j == 0 ?'loop' + i : i;
  }
}

console.log(nestedArr, nestedArr2)
```
```js
const nestedArr = [];
for (let i = 0; i < 5; i++) {
  nestedArr.push(['loop' + i, i]);
}
console.log(nestedArr);
```