repl.it
@GoodDeedNinja/

Javascript I

Nodejs

No description

fork
loading
Files
  • index.js
index.js
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
{"name": "Luke Skywalker",
  "height": "172",
  "mass": "77",
  "hair_color": "blond",
  "skin_color": "fair",
  "eye_color": "blue",
  "birth_year": "19BBY",
  "homeworld": "Tatooine",
  "films": [
    "A New Hope",
    "The Empire Strikes Back",
    "Return of the Jedi",
    "Revenge of the Sith",
    "The Force Awakens"
  ],
  "species": [
    "Human"
  ],
  "vehicles": [
    {
      "name": "Snowspeeder",
      "model": "t-47 airspeeder",
      "manufacturer": "Incom corporation",
      "cost_in_credits": null,
      "length": "4.5",
      "max_atmosphering_speed": "650",
      "crew": 2,
      "passengers": 0,
      "cargo_capacity": "10"
    },
    {
      "name": "Imperial Speeder Bike",
      "model": "74-Z speeder bike",
      "manufacturer": "Aratech Repulsor Company",
      "cost_in_credits": 8000,
      "length": "3",
      "max_atmosphering_speed": "360",
      "crew": 1,
      "passengers": 1,
      "cargo_capacity": "4"
    }
  ],
  "starships": [
    {
      "name": "X-wing",
      "model": "T-65 X-wing",
      "manufacturer": "Incom Corporation",
      "cost_in_credits": 149999,
      "length": "12.5",
      "max_atmosphering_speed": "1050",
      "crew": 1,
      "passengers": 0,
      "cargo_capacity": "110",
      "consumables": "1 week",
      "hyperdrive_rating": "1.0",
      "MGLT": "100",
      "starship_class": "Starfighter"
    },
    {
      "name": "Imperial shuttle",
      "model": "Lambda-class T-4a shuttle",
      "manufacturer": "Sienar Fleet Systems",
      "cost_in_credits": 240000,
      "length": "20",
      "max_atmosphering_speed": "850",
      "crew": 6,
      "passengers": 20,
      "cargo_capacity": "80000",
      "consumables": "2 months",
      "hyperdrive_rating": "1.0",
      "MGLT": "50",
      "starship_class": "Armed government transport"
    }
  ],
  "created": "2014-12-09T13:50:51.644000Z",
  "edited": "2014-12-20T21:17:56.891000Z",
  "url": "https://swapi.co/api/people/1/"
}



{
  "name": "Obi-Wan Kenobi",
  "height": "182",
  "mass": "77",
  "hair_color": "auburn, white",
  "skin_color": "fair",
  "eye_color": "blue-gray",
  "birth_year": "57BBY",
  "gender": "male",
  "homeworld": "Stewjon",
  "films": [
    "A New Hope",
    "The Empire Strikes Back",
    "Return of the Jedi",
    "The Phantom Menace",
    "Attack of the Clones",
    "Revenge of the Sith"
  ],
  "species": [
    "Human"
  ],
  "vehicles": [
    {
      "name": "Tribubble bongo",
      "model": "Tribubble bongo",
      "manufacturer": "Otoh Gunga Bongameken Cooperative",
      "cost_in_credits": null,
      "length": "15",
      "max_atmosphering_speed": "85",
      "crew": 1,
      "passengers": 2,
      "cargo_capacity": "1600"
    }
  ],
  "starships": [
    {
      "name": "Jedi starfighter",
      "model": "Delta-7 Aethersprite-class interceptor",
      "manufacturer": "Kuat Systems Engineering",
      "cost_in_credits": 180000,
      "length": "8",
      "max_atmosphering_speed": "1150",
      "crew": 1,
      "passengers": 0,
      "cargo_capacity": "60",
      "consumables": "7 days"
    },
    {
      "name": "Trade Federation cruiser",
      "model": "Providence-class carrier/destroyer",
      "manufacturer": "Rendili StarDrive, Free Dac Volunteers Engineering corps.",
      "cost_in_credits": 125000000,
      "length": "1088",
      "max_atmosphering_speed": "1050",
      "crew": 600,
      "passengers": 48247,
      "cargo_capacity": "50000000",
      "consumables": "4 years"
    },
    {
      "name": "Naboo star skiff",
      "model": "J-type star skiff",
      "manufacturer": "Theed Palace Space Vessel Engineering Corps/Nubia Star Drives, Incorporated",
      "cost_in_credits": null,
      "length": "29.2",
      "max_atmosphering_speed": "1050",
      "crew": 3,
      "passengers": 3,
      "cargo_capacity": null,
      "consumables": null
    },
    {
      "name": "Jedi Interceptor",
      "model": "Eta-2 Actis-class light interceptor",
      "manufacturer": "Kuat Systems Engineering",
      "cost_in_credits": 320000,
      "length": "5.47",
      "max_atmosphering_speed": "1500",
      "crew": 1,
      "passengers": 0,
      "cargo_capacity": "60",
      "consumables": "2 days"
    },
    {
      "name": "Belbullab-22 starfighter",
      "model": "Belbullab-22 starfighter",
      "manufacturer": "Feethan Ottraw Scalable Assemblies",
      "cost_in_credits": 168000,
      "length": "6.71",
      "max_atmosphering_speed": "1100",
      "crew": 1,
      "passengers": 0,
      "cargo_capacity": "140",
      "consumables": "7 days"
    }
  ],
  "created": "2014-12-10T16:16:29.192000Z",
  "edited": "2014-12-20T21:17:50.325000Z",
  "url": "https://swapi.co/api/people/10/"
}


"name": "Leia Organa",
  "height": "150",
  "mass": "49",
  "hair_color": "brown",
  "skin_color": "light",
  "eye_color": "brown",
  "birth_year": "19BBY",
  "gender": "female",
  "homeworld": "Alderaan",
  "films": [
      "A New Hope",
      "The Empire Strikes Back",
      "Return of the Jedi",
      "Revenge of the Sith",
      "The Force Awakens"
  ],
  "species": [
      "Human"
  ],
  "vehicles": [
    {
      "name": "Imperial Speeder Bike",
      "model": "74-Z speeder bike",
      "manufacturer": "Aratech Repulsor Company",
      "cost_in_credits": 8000,
      "length": "3",
      "max_atmosphering_speed": "360",
      "crew": 1,
      "passengers": 1,
      "cargo_capacity": "4"
    }
  ],
  "starships": [],
  "created": "2014-12-10T15:20:09.791000Z",
  "edited": "2014-12-20T21:17:50.315000Z",
  "url": "https://swapi.co/api/people/5/"
}






function getVehiclesCostInCreditsSumTotal(character) {
  // TODO: Add your code here.
  let total = [];
   total = character.vehicles.reduce(function(tally, value) {
    return (tally += value.cost_in_credits);
  }, 0);
  console.log(total)
}
?