-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.ts
34 lines (23 loc) · 1.13 KB
/
helper.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { formattedPlayerInterface, allPlayersInterface, responsePlayerInterface } from "./interfaces";
import axios from "axios";
class helper {
public async removeUnecessary(players: Array<formattedPlayerInterface>, count: number) {
// players.length -> total
// count -> expected
if(players.length > players.length - count) {
var final_players = []; // List that will store the final players
for(var i = 0; i < count; i++) final_players.push(players[i]); // Pushing the expected players to the list
console.log(`Got: ${players.length}, expected: ${count} -> Removing ${players.length - count}`);
console.log(final_players);
return final_players;
} else console.log(`Expected: ${count}, got ${count} -> Ignoring`)
};
public getFinalPriceSum(players: Array<responsePlayerInterface>) {
var price = 0; // Final price sum.
for(var i = 0; i < players.length; i++) {
price += players[i].preco_num;
};
return price; // Returns the final price
};
}
export default new helper();