What 🍔 burger 🍔 are you? Enter your name to find out! [Turning a string into Repeatable “Random” Numbers / Seeds]
Tags: codepen, showdev, javascript, html
Published: 2021-06-27 07:56:38

I found myself needing to create a basic system that takes a word or phrase as a seed and returns some "random numbers" that were repeatable if the same seed were entered. 

Obviously they aren't actually random but I needed something that would spit out completely different numbers for "aaaa" compared to "aaab" for example.

Think of it like a very dumbed down version of how Minecraft generates worlds based on the seed you enter.

To test it out I decided to build a "design your own burger" system based on your name or a phrase!  

As far as I can tell it works and it can actually be quite good fun trying different names and seeing if the resulting burger matches that persons personality!

## Instructions
Super simple!
### Step 1
Enter your name or a phrase in the first input (minimum 4 characters).

Your unique burger combination will show below once you have entered enough characters! Keep trying words, phrases, your name etc. until you find a beautiful burger. (it is case sensitive so try capitalised and not capitalised).

### Step 2
Once you have found a burger combination you like (or hate and think would be funny) press the "Copy Markdown to clipboard" button below the ingredients list (or select and copy all the text in the `<textarea>` below the button).

### Step 3
Paste the Markdown into a comment under the article.

Be sure to change the rating (if your burger creation isn't a 10 that is 😉) and if you want you can give your burger a silly description!

Oh and if you find a truly disgusting burger combination be sure to share that also!

## Try it out!
{% jsfiddle https://jsfiddle.net/aoc2L06p/ result %}

**Don't forget to share your creations / your username burger in the comments!**

## My favourites
Here are 3 burgers I created:

---

### The InHuOfficial Burger
![InHu Logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2qsackjzjjfacv3pvaui.gif)

I couldn't possibly not share our very own burger namesake!

Apart from the blue cheese (not a fan) it seems like a beauty, double turkey bacon **and** bacon plus halloumi...delicious!

**Username or phrase:** InHuOfficial

| Item | Ingredients |
| --- | --- |
| **Bun** | sesame seed |
| **Patties** | elk burger patty, beef burger patty |
| **Sauces** | chow chow, hot sauce, guacamole |
| **Toppings** | turkey bacon, bacon, turkey bacon |
| **Cheeses** | grilled halloumi, American cheese, blue cheese (stilton) |
| **Salads** | coleslaw |

**My rating out of 10:** 9
**My super serious description 😉:** Eating this burger will improve your accessibility skills 200%!

---

### The Independence Day burger
!["4th July Independence Day" with American flag and balloons](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vsp69usbu5etk1rbj8l1.jpg)

Had to fiddle a little bit to get a burger fit for America!

Three patties, American Cheese and a double helping of sweet potato fries seems like a good fit!

**Username or phrase:** 04th July

| Item | Ingredients |
| --- | --- |
| **Bun** | crusty |
| **Patties** | chicken breast burger patty, beef burger patty, bean burger patty |
| **Sauces** | ranch dressing, chimichurri, sweet chilli |
| **Toppings** | sweet potato fries, serrano ham, sweet potato fries |
| **Cheeses** | american cheese |
| **Salads** | lettuce, gherkin / pickles |

**My rating out of 10:** 8
**My super serious description 😉:** Nearly all American, if anything it perfectly reflects America in 2021 - American at the core with a nice sprinkling of flavours from other Countries and cultures to keep it interesting. A must try this July 4th!

---

## The Ben Burger
![Ben Halpern profile pix](https://res.cloudinary.com/practicaldev/image/fetch/s--99Dq5PZH--/c_fill,f_auto,fl_progressive,h_320,q_auto,w_320/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/1/f451a206-11c8-4e3d-8936-143d0a7e65bb.png)
How could we not include dev.to founder Ben?

The hilarious thing is it is an Elk burger (that is a Canadian thing right? Sorry I am an ignorant Brit)...**and it has Maple Syrup on it**....I couldn't stop laughing at the sterotype 😋🤣🤣!

In all seriousness though I think this sounds like it could be delicious! Joe Rogan would obviously approve given his obsession with Elk!

**Username or phrase:** Ben Halpern

| Item | Ingredients |
| --- | --- |
| **Bun** | sesame seed |
| **Patties** | elk burger patty |
| **Sauces** | maple syrup, bbq |
| **Toppings** | serrano ham, onion rings, pulled pork |
| **Cheeses** | american cheese, goats cheese |
| **Salads** | coleslaw, roasted red peppers |

**My rating out of 10:** 10
**My super serious description 😉:** This burger proves Ben is Canadian. I don't think I could have made it better if I tried! 🤣🤣

## A few little bits
No tutorial for this one, just some interesting bits of info.

There are over 29 BILLION different burgers that this generator can create. 

If you ate one variation a day it would take you 79.6 million years to try them all.

It is probably flawed due to the way I built it so maybe there will be duplicates. It is just a silly project after all and my brain hurts already. If someone sees a flaw please point it out.

If you want to dig into my shoddy code here is a link to the fiddle: https://jsfiddle.net/aoc2L06p/

The key is
``` Javascript
var seededRandom = function(seed, max, min) {
    max = max || 1000000000;
    min = min || 137;
 
    seed = (seed * 9301 + 49297) % 233280;
    var rnd = seed / 233280;
    
    return Math.round(min + rnd * (max - min), 0);
}
```

Apparently the numbers used on lines 5 and 6 are carefully calculated to produce a very even appearance of random numbers. 

Unfortunately I couldn't track down the article that explained it.

## Conclusion
From my testing it appears to work fine. The actual `seededRandom` function does what I need it to do and that was where this all started.

So what is YOUR Burger? Does your name create a better burger than "Ben Halpern", "InHuOfficial" or "04th July"? Give it a try!

[![Click to Tweet: "So what is YOUR Burger? Does your name create a better burger than "Ben Halpern", "InHuOfficial" or "04th July"? Give it a try!"](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dz3g7b8w4ofhw3notwn5.jpg)](https://twitter.com/intent/tweet?url=https://dev.to/inhuofficial/what-burger-are-you-enter-your-name-to-find-out-repeatable-random-numbers-seeds-3jhf&text=%22So%20what%20is%20YOUR%20Burger?%20Does%20your%20name%20create%20a%20better%20burger%20than%20%22Ben%20Halpern%22,%20%22InHuOfficial%22%20or%20%2204th%20July%22?%20Give%20it%20a%20try!%22%20-%20@InHuOfficial%20)