# Generate Unique Random Words per User

**URL:** <https://community.glideapps.com/t/generate-unique-random-words-per-user/77321>\
**Category:** Ask for Help\
**Created:** [October 25, 2024, 6:13am UTC](https://community.glideapps.com/t/generate-unique-random-words-per-user/77321 "2024-10-25T06:13:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![taleno.digital](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/taleno.digital/32/47944_2.png) [@taleno.digital](https://community.glideapps.com/u/taleno.digital)\
**Post date:** [October 25, 2024, 6:13am UTC](https://community.glideapps.com/t/generate-unique-random-words-per-user/77321/1 "2024-10-25T06:13:57Z")

</div>

Hi Team,

How to generate a unique but random words per user? Like for example, bluecarrot123, redbanana456.

But every user must have a unique random words.

Thanks in advance for help!

---

<div class="post-metadata">

**Author:** ![Himaladin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/himaladin/32/71023_2.png) [@Himaladin](https://community.glideapps.com/u/Himaladin)\
**Post date:** [October 25, 2024, 6:52am UTC](https://community.glideapps.com/t/generate-unique-random-words-per-user/77321/2 "2024-10-25T06:52:29Z")

</div>

If you want it to be unique and stable for each user, then the last number (p1) should use rowId, or you can create a stable number from a random column.  
Example result: **redbananadYY**

```auto
function hashString(str) {
    let hash = 0;
    for (let i = 0; i < str.length; i++) {
        hash = (hash << 5) - hash + str.charCodeAt(i);
        hash |= 0; 
    }
    return Math.abs(hash); 
}

function generateUniqueName(rowID) {
    rowID = String(rowID); 

    const adjectives = ["blue", "red", "green", "happy", "silly"];
    const nouns = ["carrot", "banana", "apple", "orange", "grape"];

    const hash = hashString(rowID);

    const adjective = adjectives[hash % adjectives.length];
    const noun = nouns[(hash >> 2) % nouns.length]; 

    const lastThreeChars = rowID.slice(-3); 

    return `${adjective}${noun}${lastThreeChars}`; 
}

return generateUniqueName(p1);

```

---

<div class="post-metadata">

**Author:** ![micheal](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/micheal/32/80181_2.png) [@micheal](https://community.glideapps.com/u/micheal)\
**Post date:** [October 25, 2024, 7:17am UTC](https://community.glideapps.com/t/generate-unique-random-words-per-user/77321/3 "2024-10-25T07:17:27Z")

</div>

this is awesome [Himaladin](https://community.glideapps.com/u/Himaladin) I was just about to try this out but this is neat you could even customize this further

---

<div class="post-metadata">

**Author:** ![taleno.digital](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/taleno.digital/32/47944_2.png) [@taleno.digital](https://community.glideapps.com/u/taleno.digital)\
**Post date:** [October 25, 2024, 7:43am UTC](https://community.glideapps.com/t/generate-unique-random-words-per-user/77321/4 "2024-10-25T07:43:58Z")

</div>

Thanks @Himaladin ! Is there a way to not have those words hard coded? Can it generate a word based from the row number?

---

<div class="post-metadata">

**Author:** ![Himaladin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/himaladin/32/71023_2.png) [@Himaladin](https://community.glideapps.com/u/Himaladin)\
**Post date:** [October 25, 2024, 7:48am UTC](https://community.glideapps.com/t/generate-unique-random-words-per-user/77321/5 "2024-10-25T07:48:54Z")

</div>

You can use numbers from random columns as I mentioned. If you want row numbers, just create a row number and replace p1 with your row number column.  
I have edited the script a bit to take the last 3 numbers.

 ![Screenshot 2024-10-25 at 14.51.00](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/b/4/b4d22db0867fefb9565252908220148da5b14aee.png)

---

<div class="post-metadata">

**Author:** ![Himaladin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/himaladin/32/71023_2.png) [@Himaladin](https://community.glideapps.com/u/Himaladin)\
**Post date:** [October 25, 2024, 8:09am UTC](https://community.glideapps.com/t/generate-unique-random-words-per-user/77321/6 "2024-10-25T08:09:16Z")

</div>

Do you know how to create row numbers?

---

<div class="post-metadata">

**Author:** ![micheal](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/micheal/32/80181_2.png) [@micheal](https://community.glideapps.com/u/micheal)\
**Post date:** [October 25, 2024, 8:18pm UTC](https://community.glideapps.com/t/generate-unique-random-words-per-user/77321/7 "2024-10-25T20:18:21Z")

</div>

Like himaladin said you’d need to have some basic value elsewhere already… an option is to use AI to do this directly but I wouldn’t want to use it for something so generic
