Question: This sounds to me quite simple, but i guess i am missing something.

I have the following class:

```
 public class Difficulty
    {

        public int Fractional;
        public int ArtistMax;

        private readonly List<Difficulty> QuestionDifficultyList = new List<Difficulty>();

        public Difficulty()
        {
            PopulateDifficultyData();
        }
        public void PopulateDifficultyData()
        {
            Difficulty item = new Difficulty
            {
                Fractional = 3,
                ArtistMax = 30
            };
            QuestionDifficultyList.Add(item);
         }
    }

```

When calling to initialize the class: 

```
  Difficulty DifficultyData = new Difficulty();

```

It will execute the constructor endlessly. 

What is the approach that should be used for this scenario?
I need to populate class List with some values.

Answer: 
You can flatten the array using `concat` and `map`. Use `reduce` to get the percetange.

```js
let arr = [{"id":"5b221edea8abbc4194a62b90","name":"Job one","tasks":[{"id":"5b221edea8abbc4194a62b91","name":"Task 2","status":"finished"},{"id":"5b221edea8abbc4194a62b91","name":"Task 3","status":"pending"},{"id":"5b221edea8abbc4194a62b91","name":"Task 3","status":"to_do"}]},{"id":"5b221edea8abbc4194a62b91","name":"Job two","tasks":[{"id":"5b221edea8abbc4194a62b96","name":"Task 5","status":"finished"},{"id":"5b221edea8abbc4194a62b97","name":"Task 8","status":"accepted"}]}]

let result = [].concat(...arr.map(o => o.tasks)).reduce((c, {status}) => {
  if (status === "finished") c.finished++;
  c.total++;
  c.percentage = (c.finished / c.total) * 100;
  return c;
}, {finished: 0,total: 0,percentage: 0})

console.log(result);
```
You can simply use nested `forEach` for calculating the percentage.

Try the following:

```js
var arr =  [{"id":"5b221edea8abbc4194a62b90","name":"Job one","tasks":[{"id":"5b221edea8abbc4194a62b91","name":"Task 2","status":"finished"},{"id":"5b221edea8abbc4194a62b91","name":"Task 3","status":"pending"},{"id":"5b221edea8abbc4194a62b91","name":"Task 3","status":"to_do"}]},{"id":"5b221edea8abbc4194a62b91","name":"Job two","tasks":[{"id":"5b221edea8abbc4194a62b96","name":"Task 5","status":"finished"},{"id":"5b221edea8abbc4194a62b97","name":"Task 8","status":"accepted"}]}];

var completedCount = 0;
var total = 0;
arr.forEach((o)=>{
  o.tasks.forEach((task) => {
    if(task.status == "finished")
      completedCount++;
     total++;
  });
});
var percentage  = (completedCount/total)*100;
console.log(percentage+"%");
```