1 00:00:00,180 --> 00:00:03,870 Before we start, did you try solving the workbook yourself? 2 00:00:03,900 --> 00:00:09,660 If not, please click the link in the resources folder and follow the instructions for this workbook. 3 00:00:10,500 --> 00:00:14,280 Workbook 6.6 is an extension of workbook 6.5. 4 00:00:14,280 --> 00:00:18,930 We should only have one task that is to create a variable seat that starts at zero. 5 00:00:18,930 --> 00:00:20,340 Simple enough. 6 00:00:21,640 --> 00:00:27,610 And then it says using a for loop, find the number that matches the highest score and print it. 7 00:00:27,640 --> 00:00:32,990 The index that corresponds to the highest score is the one where this condition evaluates to true. 8 00:00:33,010 --> 00:00:36,130 So here we can say seat is equal to I. 9 00:00:37,170 --> 00:00:38,580 And that's all here. 10 00:00:38,580 --> 00:00:44,490 We can just say it's the gentleman in seat, the seat number that matches the highest score. 11 00:00:46,470 --> 00:00:48,460 And that was really it. 12 00:00:48,480 --> 00:00:49,590 Nothing to it. 13 00:00:49,680 --> 00:00:51,390 And let's visualize the runtime. 14 00:00:51,870 --> 00:00:52,320 You know what? 15 00:00:52,320 --> 00:00:55,890 We need one breakpoint right beside the for loop. 16 00:00:56,130 --> 00:00:57,150 And that's all. 17 00:01:00,840 --> 00:01:02,490 Let me clean up over here. 18 00:01:04,080 --> 00:01:05,180 Expand this. 19 00:01:05,190 --> 00:01:10,140 So here we see our scores array has ten different random numbers. 20 00:01:10,140 --> 00:01:14,190 We can see that the highest number is that index number one, actually. 21 00:01:14,850 --> 00:01:16,980 So first I start at zero. 22 00:01:18,570 --> 00:01:21,420 The score at index zero is 22,000. 23 00:01:22,220 --> 00:01:25,880 22,000 is greater than our current high score of zero. 24 00:01:25,880 --> 00:01:31,670 So this evaluates to true setting our high score equal to the highest score we've encountered so far. 25 00:01:32,390 --> 00:01:36,590 And now the seat number equals the index that corresponds to this high score. 26 00:01:37,880 --> 00:01:39,500 Now I equals one. 27 00:01:40,740 --> 00:01:45,420 The score at index one 43,000 is greater than our current highest score. 28 00:01:45,420 --> 00:01:47,720 So we update our high score again. 29 00:01:47,730 --> 00:01:55,080 Now our high score is 43,000 and we set seat equal to the index that corresponds to this high score. 30 00:01:56,180 --> 00:01:58,100 So now seat equals one. 31 00:01:58,960 --> 00:02:02,970 And none of these scores are going to be greater than our current high score. 32 00:02:02,980 --> 00:02:06,580 So this if statement is always going to evaluate the false. 33 00:02:07,840 --> 00:02:10,509 Until the for loop eventually runs to completion. 34 00:02:14,940 --> 00:02:15,480 All right. 35 00:02:15,480 --> 00:02:19,500 So the highest score in the array ended up being 43,000. 36 00:02:20,510 --> 00:02:24,440 And the seat number that corresponds to the score is C to one. 37 00:02:26,530 --> 00:02:27,120 That was it. 38 00:02:27,130 --> 00:02:29,410 I hope you enjoyed this breakpoint session.