Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Fontbonne and Lakeland have a famous volleyball rivalry dating back to 2010. The number of points each team has scored in head-to-head competition over five

Fontbonne and Lakeland have a famous volleyball rivalry dating back to 2010.

The number of points each team has scored in head-to-head competition over five years is provided in the griffinScores and muskiesScores arrays.

Ex: Lakeland won the first game 76-72 since griffinScores[0] is 72 and muskiesScores[0] is 76.

  1. Write a for loop that examines the griffinScores and muskiesScores arrays and places F in the winningTeam array if Fontbonne won or L if Lakeland won, for every game. Ex: winningTeam[0] should be L because Lakeland won 76-72, and winningTeam[1] should be F because Fontbonne won 74-73.

  2. Print the contents of the winningTeam array using a for-of loop.

  3. Write a forEach() loop that examines the winningTeam array and determines the longest streak of Fontbonne wins. Print the longest streak to the console, which should be 4.

In order to figure out the longest streak, employ two variables initialized to 0: winStreak and longestStreak. Loop through the winningTeam array. Every time a F appears, increment winStreak and then update longestStreak if winStreak > longestStreak. When an L is encountered, reset winStreak back to 0. When the loop terminates, longestStreak will contain the longest streak.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

6th Edition

1943153035, 978-1943153039

More Books

Students also viewed these Databases questions