```js
for (var i = 1; i <= 4; i++) {
  var str = "";
  for (var j = 1; j <= i; j++) {
    str = str + i;
  }
  console.log(str);
}
```

This is the code I Perform But its Wrong

```
1
23
456
78910

```

anybody please help?
['https://Stackoverflow.com/questions/67646455', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/15997945/']
```js
var current_value = 1;
for (var i = 1; i <= 4; i++) {
  var str = "";
  for (var j = 1; j <= i; j++) {
    str = str + current_value++;
  }
  console.log(str);
}
```
This is how I would solve your problem. You can use [`Array.prototype.map()`](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Array/map) in order to create loops easily. If we now create an empty array with 5 indexes we can use the [`Array.prototype.keys()`](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Array/keys) to get an array of values from 0 to 4. Besides that my code follows the same concept with using an empty string (`res`) and adding values to it.
Also we mustn't forget to check if `res` is still empty.

```js
let v = 1;
[...Array(5).keys()].map((i) => {
  let res = "";
  [...Array(i)].map(() => (res = res + v++));
  res && console.log(res);
});
```

**Edit:**

I just realized the `.keys()` is not even needed because simply using the index has the same effect:

```js
let v = 1;
[...Array(5)].map((_, i) => {
  let res = "";
  [...Array(i)].map(() => (res = res + v++));
  res && console.log(res);
});
```