Mixed Messages - Mad Libs

Hello, I am working on a Mad Libs generator for the Mixed Messages project. I’ve included the main functionality below. I used a switch statement for the parts of speech. I believe that I can further abstract this but the syntax is eluding me. Does anyone have any ideas?

For example:

const getWord = (partOfSpeech) => {
  let array = partOfSpeech.nouns; // <- Here I want to replace "noun" with a variable that reflects the array in each part
  // of speech file, which is named the same as the file name
  let randomIndex = Math.floor(Math.random() * array.length);
  let word = array[randomIndex];
  return word;

Example part of speech file:

const adverbs = [
  'abashedly' ...

module.exports = { adverbs }

Main functionality:

const adjectives = require('./words/parts-of-speech/adjectives');
const adverbs = require('./words/parts-of-speech/adverbs');
const articlesOfClothing = require('./words/parts-of-speech/articles-of-clothing');
const citizenNames = require('./words/parts-of-speech/citizen-names');
const countries = require('./words/parts-of-speech/countries');
const nouns = require('./words/parts-of-speech/nouns');
const places = require('./words/parts-of-speech/places');
const pluralNouns = require('./words/parts-of-speech/nouns');
const properNouns = require('./words/parts-of-speech/proper-nouns');
const verbs = require('./words/parts-of-speech/nouns');

const getRandomNumber = (max) => {
  let randomNumber = Math.floor(Math.random() * max);
  return randomNumber;

const getWord = (partOfSpeech) => {
  let array;
  switch (partOfSpeech) {
    case adjectives:
      array = partOfSpeech.adjectives;
    case adverbs:
      array = partOfSpeech.adverbs;
    case articlesOfClothing:
      array = partOfSpeech.articlesOfClothing;
    case citizenNames:
      array = partOfSpeech.citizenNames;
    case countries:
      array = partOfSpeech.countries;
    case nouns:
      array = partOfSpeech.nouns;
    case places:
      array = partOfSpeech.places;
    case pluralNouns:
      array = partOfSpeech.pluralNouns;
    case properNouns:
      array = partOfSpeech.properNouns;
    case verbs:
      array = partOfSpeech.verbs;
  let randomIndex = Math.floor(Math.random() * array.length);
  let word = array[randomIndex];
  return word;

const weatherReport = `
Here is tomorrow's weather report for ${getWord(countries)} and vicinity.
Early tomorrow, a ${getWord(adjectives)} front will
collide with a mass of hot ${getWord(pluralNouns)} moving from the
north. This means we can expect ${getWord(adjectives)} winds and
occasional ${getWord(pluralNouns)} by late afternoon. Wind velocity will
be ${getRandomNumber(1000)} miles an hour, and the high temperature should
be around ${getRandomNumber(200)} degrees. So, if you're going out, you had
better plan on wearing your ${getWord(articlesOfClothing)}.


// BTW this weather report is totally ripped off from a Mad Libs website - I’ll get creative later :slight_smile: