JSFiddle - React, Tailwind, and code Playground

by Sander Datema

HTML

<div id="text-content"></div>

JavaScript

var words = [ "one", "two", "three", "four", "five", "six", "seven" ];
$( "#text-content" ).text( createNewWord( words ) ); 

function getRandomWord( wordsArray ) {
    var index = Math.floor( Math.random() * wordsArray.length );
    return wordsArray[index];
}

function createNewWord( wordsArray ) {
       
    var newWordPart1 = getRandomWord( wordsArray );
    var newWordPart2 = getRandomWord( wordsArray );
    
    // this will prevent new words like oneone twotwo, etc.
    // if you want the repeated words, just remove this while entirely
    while ( newWordPart2 == newWordPart1 ) {
        newWordPart2 = getRandomWord( wordsArray );
    }
    
    return newWordPart1 + newWordPart2;
    
}