I have a @State private var usedWords = String
this array store the history of words that are used in the game
I have a property that counts the letters of every single letter in each word from the above array by using .count
I want to create a new variable that counts every letter in all the words in the above array
3
Answers
You should look into the array instance method reduce. Example:
If you have state property your solution mb like this:
Every change of usedWords property will trigger view redraw and recalculation of lettersCount computed property, thats why view will always use actual value of lettersCount.
Letters counting was used from JLM answer.
You can do the following:
Complete example:
}