Here is an example on jsfiddle

var words = ["monitor", "program", "application", "keyboard", "javascript", "gaming", "network"];

var word = words[Math.floor(Math.random() * words.length)];

console.log(word);

document.getElementById("word").textContent = word;

And to have it fit in directly with you present code:

var getRandomWord = function () {
    return words[Math.floor(Math.random() * words.length)];
};
Answer from Xotic750 on Stack Overflow
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Can JS create truly random words? - JavaScript - The freeCodeCamp Forum
November 9, 2022 - I know that JS can select a random value from an array of predefined content. But is it possible for JS to create a truly random word? Without an array that tells it what to choose from? And if so, how can I do that? I’m using Javascript to code a RNG algorithm for a videogame art project in which I let JS decide on the contents of the video in order to make it truly random (things such as shot length, shot contents, F-stop values etc.
Discussions

How can I make a function that chooses a random word everytime I recharge the page?
You could use an external api that returns a different word every time you hit it. You can have a constant of words to map through. This means you'll create a function that returns a random number, between 0 to say length of your words constant array. Then use the random number as index to return the item in the array with that index. Goodluck! More on reddit.com
🌐 r/learnjavascript
12
1
January 28, 2024
javascript - Create N digit random words from an array - Stack Overflow
I want to create a 4 digit random word from this array. More on stackoverflow.com
🌐 stackoverflow.com
How to generate random words in JavaScript? - Stack Overflow
Possible Duplicate: Getting a random value from a JavaScript array OK, so I have three variables here, each being rock, paper or scissors. Using JavaScript, how can I generate one of those words More on stackoverflow.com
🌐 stackoverflow.com
Randomize wordset javascript array - Stack Overflow
This is clean but some times the ... sure the word combo is only ran once? ... @DangolBeeker I do not understand your question. if you repeat your draw, whatever the method used, it will always be possible for 2 successive draws to return the same pairs of values to you. ... A standard algorithm to select a random number, say r elements from an array, n long is ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Dev By RayRay
hasnode.byrayray.dev › create-your-own-ipsum-generator-with-javascript
Create Your Own Ipsum Generator With JavaScript
January 31, 2022 - Generate a string with random words with JavaScript. Use it for testing or build your own Ipsum generator.
🌐
EncodedNA
encodedna.com › javascript › random-word-generator.htm
JavaScript Random Word Generator - EncodeDna.com
What's interesting is how it picks up a random word from the list of predefined array. See the below code. let randomIndex = Math.floor(Math.random() * words.length); Array elements in JavaScript are accessed using the index number. The index starts with zero, followed by one and so on.The ...
Find elsewhere
🌐
Sololearn
sololearn.com › en › Discuss › 2591529 › how-to-select-get-random-word-from-list-using-javascript
How to select/get random word from list using JavaScript? | Sololearn: Learn to code for FREE!
November 16, 2020 - We have function Math.random() that returns a random floating point number m, 0<=m<1. So you can just multiply the returned value by length, and take integer part (for example with Math.floor) Depending on your application you might need better implementations of random (more secure, better equidistributed, or just having better control over inner state - if that's the case you should search for javascript random number libraries with the properties you need)
🌐
Kirupa
kirupa.com › html5 › picking_random_item_from_array.htm
Picking a Random Item from an Array | kirupa.com
I put all of my choices into an array and write some JavaScript to randomly pick a choice - a choice that I unquestioningly follow. In this article, we will learn how to write this JavaScript ourselves. We will learn how to write some code to randomly pick an item from array filled with items!
🌐
CSS-Tricks
css-tricks.com › snippets › javascript › select-random-item-array
Select Random Item from an Array | CSS-Tricks
December 23, 2016 - JS Result EDIT ON function randomNum(minVal, maxVal) { do { r = Math.random(); } while (r == 1); return minVal+Math.floor(r*(maxVal+1-minVal)); } var coolwords = new Array(); coolwords[0] = “robot”; coolwords[1] = “inferno”; coolwords[2] = “giga”; coolwords[3] = “infinity”; coolwords[4] = “pow”; coolwords[5] = “smash”; coolwords[6] = “boom”; coolwords[7] = “crunch”; coolwords[8] = “robot”; coolwords[9] = “inferno”;
🌐
W3Resource
w3resource.com › javascript-exercises › javascript-array-exercise-35.php
JavaScript array: Get a random item from an array - w3resource
July 12, 2025 - // Function to return a random item from an array function random_item(items) { // Use Math.random() to generate a random number between 0 and 1, // multiply it by the length of the array, and use Math.floor() to round down to the nearest integer ...
🌐
GitHub
github.com › djbrieck › get-random-word
GitHub - djbrieck/get-random-word: Given a list of words, a basic javascript function to return a random word each time its called.
Given a list of words, a basic javascript function to return a random word each time its called. - djbrieck/get-random-word
Author   djbrieck
🌐
npm
npmjs.com › package › random-words
random-words - npm
The underlying implementation of this option utilizes the seedrandom package as a replacement for Math.random(). The count function can be used to calculate the total number of words in the word list that meet the specified minimum and maximum length criteria. ... import { generate, count } from "random-words"; console.log(generate()); //output: 'army' console.log(generate(5)); //output: ['army', 'beautiful', 'became', 'if', 'actually'] console.log(generate({ minLength: 2 })); //output: 'hello' console.log(generate({ maxLength: 6 })); //output: 'blue' console.log(generate({ minLength: 5, maxLe
      » npm install random-words
    
Published   Jan 25, 2024
Version   2.0.1
Author   Apostrophe Technologies
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-select-a-random-element-from-array-in-javascript
JavaScript – Select a Random Element from JS Array | GeeksforGeeks
Selecting a random element from array in JavaScript is done by accessing an element using random index from the array.
Published   January 9, 2025