calculateScore method

  1. @override
int calculateScore(
  1. dynamic result
)
override

Score is the sum of correct answers in the list of results that match the words in the list of words.

Implementation

@override
int calculateScore(dynamic result) {
  int sum = 0;
  try {
    List<String> wordList = result['wordsList'] as List<String>;
    List<String> resultsList = result['resultsList'] as List<String>;
    resultsList = resultsList.map((result) => result.toLowerCase()).toList();
    for (int i = 0; i < resultsList.length; i++) {
      if (wordList.contains(resultsList[i])) sum++;
    }
  } catch (error) {
    print('$runtimeType - $error');
  }
  return sum;
}