We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Arrays

The most common way to declare an array is using the bracket notation, string[], number[], etc.:

function trainJedi(jediKnights: string[]) {
  for (let knight of jediKnights) {
    console.log(`Training ${knight}...`);
  }
}

trainJedi(["Dooku", "Qui-Gon", "Xanatos"]);
// Training Dooku...
// Training Qui-Gon...
// Training Xanatos...

Assignment

Support.ai needs to calculate the performance scores for their support agents. Each agent receives customer ratings for their support interactions.

Complete the averageScore function. It takes an array of customer ratings numbers as input and returns their average score.

If the array is empty, return 0.