# Get the sum of the values of the same label from the struct

I need to add the unappeared to the Array from this information. If there is a duplicate, the money will be summed up and then saved into one. How can I achieve this? The data may be a lot.

I need to add the unappeared to the Array from this information. If there is a duplicate, the money will be summed up and then saved into one. How can I achieve this? The data may be a lot.

```import UIKit
struct TestData {
let Label : String
var Money : Double
}
var SaveDate = TestData
var TestD = TestData
SaveDate.append(TestData(Label: "test1", Money: 55))
SaveDate.append(TestData(Label: "test1", Money: 35))
SaveDate.append(TestData(Label: "test2" , Money: 15))
SaveDate.append(TestData(Label: "test1" , Money: 10))
SaveDate.append(TestData(Label: "test3" , Money: 30))
print([{Label "test1", Money 55}, {Label "test1", Money 35}, {Label "test2", Money 15},{Label "test1", Money 10}, {Label "test3", Money 30}])
//Result presentation
//Label1 = test1 , Money = 100
//Label2 = test2 , Money = 15
//Label3 = test3 , Money = 30
```

## How to group multiple sets of duplicate integers in an array into their own array of arrays?

I am trying to split an array of integers into an array of arrays by duplicate values. The original array is composed of a list of 6 digit integers, some of these integers come in pairs, others come in groups of 3 or 4s. I'd like to get these duplicates pushed to their own arrays and have all of these arrays of duplicates composed into an array of arrays that I can later loop through.

I am trying to split an array of integers into an array of arrays by duplicate values. The original array is composed of a list of 6 digit integers, some of these integers come in pairs, others come in groups of 3 or 4s. I'd like to get these duplicates pushed to their own arrays and have all of these arrays of duplicates composed into an array of arrays that I can later loop through.

I've looked on in the lodash library for some method or combination of but can't quite find anything that seems to work. I've also tried a few different configurations with nested for loops but also am struggling with that.

```const directory = "X/";
let first6Array = [ ];
for(i=0; i< files.length; i++){
let first6 = files[i].substring(0, 6);
first6Array.push(first6);
};
console.log(first6Array);
```

example output of first6Array: [ '141848', '141848', '141848', '142851', '142851', '143275', '143275']

I'd like to end up with something like

let MasterArray = [[141848,141848,141848],[142851,142851],[143275,143275]];

## Converting array to Double and work with its content

I'm kinda new to Swift, and I'm trying to create a command-line program: at first, it should get 3 (exactly 3, not more or less, and divided by spaces) numbers from user via standard input and apply them in trigonometric calculations later. As far as I understand, I should use readLine() function to get the user input in terminal, and also put those values into array to not repeat myself and write same code for every value.

I'm kinda new to Swift, and I'm trying to create a command-line program: at first, it should get 3 (exactly 3, not more or less, and divided by spaces) numbers from user via standard input and apply them in trigonometric calculations later. As far as I understand, I should use readLine() function to get the user input in terminal, and also put those values into array to not repeat myself and write same code for every value.

But this is the point where difficulties begin: even though I could've convert single readLine() value (which is String optional) to Double, in my situation I need to get an array, convert all of the values and also check if user input is correct. In case the user has entered incorrect value or values (random symbols or words instead of numbers, for example) I need to display an error message and return him to start of the program, i.e. ask user to enter the numbers again. How do I do that?

## Array of Arrays in Angular Class

I'm new to Angular and cant really grasp how to loop through an array inside an array.

I'm new to Angular and cant really grasp how to loop through an array inside an array.

I'm trying to achieve same thing as the following C code:

```   for (int i = 0; i < 10; i ++){
printf ("%d", ar[i]);
```   for (int j =0; j &lt; 3; j ++ )
{
printf ("%d", arre[j]);
}
printf ("\n");
```
}
```

But in my case I have a class:

```class Arende{
Id:number
Namn :string
Status :string
RegistreringLista :Registrering[]
}
```

HTML:

```    <tr *ngFor="let arende of arenden">
<td> {{arende.Id}} </td>
<td> {{arende.Namn}}</td>
<td> {{arende.RegistreringLista.xxxx}}</td>
<td> {{arende.RegistreringLista.yyyy}}</td>
<td> {{arende.ResitreringsLista.zzzzz}}</td>
```

I thought that there should be some way to do a:

```<tr *ngFor="let arende of RegistreingsLista">
```

But that dosen't seem right either ... I have trouble understanding the loop sequence ... How should I set it up?