1 00:00:00,470 --> 00:00:03,580 In this challenge we need to use the forEach method 2 00:00:03,580 --> 00:00:08,170 to turn the number strings in the stringPrices array into floats. 3 00:00:08,170 --> 00:00:10,110 And then we need to add them all together, 4 00:00:10,110 --> 00:00:13,660 storing the total in the variable named total. 5 00:00:13,660 --> 00:00:15,550 I'll start with copy and pasting the code for 6 00:00:15,550 --> 00:00:19,150 this challenge into Atom in order to make the code easier to read. 7 00:00:23,250 --> 00:00:26,630 Again, I started by adding the call to the forEach method. 8 00:00:26,630 --> 00:00:30,721 And then the anonymous callback function using arrow function syntax. 9 00:00:30,721 --> 00:00:35,665 So, stringPrices.forEach. 10 00:00:35,665 --> 00:00:41,090 And I use stringPrice for the current value parameter name, followed by a fat 11 00:00:41,090 --> 00:00:47,650 arrow For the function body, I added a set of curly braces to define a code block. 12 00:00:47,650 --> 00:00:52,020 Each price is a string, so we need to convert it to a number before we can 13 00:00:52,020 --> 00:00:55,170 successfully add it to the priceTotal variable. 14 00:00:55,170 --> 00:00:57,890 To do that, I use the parseFloat function. 15 00:00:57,890 --> 00:00:59,640 First, let's define a variable. 16 00:00:59,640 --> 00:01:07,880 So const price equals parseFloat(stringPrice). 17 00:01:09,920 --> 00:01:13,336 Then I use the addition assignment operator to add 18 00:01:13,336 --> 00:01:16,599 the current price to the priceTotal variable. 19 00:01:16,599 --> 00:01:21,080 priceTotal += price;. 20 00:01:21,080 --> 00:01:22,890 And that's my solution. 21 00:01:22,890 --> 00:01:24,978 Like we did with the previous example, 22 00:01:24,978 --> 00:01:27,961 you could eliminate the intermediate variable price. 23 00:01:31,815 --> 00:01:35,222 Cut this code, delete that line, and 24 00:01:35,222 --> 00:01:39,410 replace price here of the call to parseFloat. 25 00:01:39,410 --> 00:01:42,243 And we could also eliminate the curly braces. 26 00:01:44,875 --> 00:01:46,340 Nice job. 27 00:01:46,340 --> 00:01:48,941 Coming up, the next challenge of the course. 28 00:01:48,941 --> 00:01:50,250 And we'll see you after that.