So basically I have an array with a ton of words. I want to achieve a new array that holds the word and amount of the word as properties of an object. Like so:
const arrayWithWords = [`word1`, `word2`, `word5`, `word1`, `word3`, `word6`, `word2`, `word3`, `word1`, `word5`]
// and I want to achieve the array below
const newArray = [ {name: `word1`, amount: 3} {name: `word2`, amount: 2} {name: `word3`, amount: 2} {name: `word4`, amount: 0} {name: `word5`, amount: 2} {name: `word6`, amount:1}]
I've tried using the for-loop but I'm always getting stuck. What could be a possible solution for this?