async function fetchWordsInArr(arr, command) {
let newArr = [];
for (var i = 0; i < arr.length; i++) {
let w = arr[i].word;
let url = `https://api.datamuse.com/words?${command}=${w}`;
let response = await fetch(url);
let resJson = await response.json();
let newWord;
if (isEmpty(resJson)) {
newWord = w;
} else {
newWord = resJson[0].word;
}
newArr[i] = { word: newWord, loc: arr[i].loc };
}
return newArr;
}