score:0

for one, fetch is asynchronous, so you have to wait for it to finish.
which is why you have then methods.

however, you're trying to sort keyz before keyz has any data.

move the sort function into the then method,
after wordcount where keyz is filled.
and calling compare on its own, does nothing...

// fetch json file locally and return the data
fetch('../test_feed.json')
  .then(res => res.json())
  .then(data => {
    handletweettext(data)
    wordcount()
    keyz.sort(compare)
    createchart()
  })
.catch(err => console.error(err));

but typically, you don't use the same data for both labels and data in the chart.
is it possible you meant to use counts for data in the chart?


Related Query

More Query from same tag