🍴 What Should I Eat? 🍜

Food options tool for people who can't remember what they like

Overview

I created this script for myself to help with choosing restaurant food. I eat out a few times a month and usually it's just "I want to pay someone else to make me food," rather than "I have a craving for a certain thing." Every time I wish I had a list of ALL the things I like so I could just pick from that, rather than browsing each menu for takeout options.

That's when I got the idea for this. I learned a little bit about Javascript: Adding data, randomizing/displaying options, history, filtering... and a bit about CSS to get things to operate the way I wanted them to.

I'm providing the script and basic instructions so you can update it with your foods, if you think something simple like this might be helpful. Basically, you fill out the database (foods.js) with foods and restaurants near you that you reliably enjoy, providing details about each dish's cost and distance from your home.

See the note at the bottom of the page about making updates yourself.

What it Do

Use the tool:

  1. Pick the Max Cost from the drop-down. Cost is associated with each dish and dishes include starters, entrees, desserts, sides, and drinks.
  2. Type the Max Distance. I do takeout so this helps me estimate how long it'll take to drive there, and I can filter to closer places if I want to...
  3. Select Help! to get a random selection of items from your database.
  4. Results:
    • 3 randomized options to choose from
    • 5 past results (in case I push Help again and want to compare with what I saw before) - this resets per session

Files

Right click and download the associated files.

Instructions

Follow these instructions to add your food selections to the database for your tool. You can update the index and style files as desired.

  1. Open food.js in your preferred editor.
  2. The file is structured to accomodate an entry for each restaurant I like and multiple dishes from the menu. Each restaurant looks like the code below with a line for each dish.
    {
    name: "Delias",
    mileage: 5,
    dishes: [
    { name: "Beets and Goat Cheese Salad", cost: 11 },
    { name: "10 in Pizza (gluten free crust)", cost: 12 },
    { name: "Burger (gluten free bun) and fries", cost: 19 },
    { name: "Chocolate Mousse", cost: 8 },
    { name: "Creme Brulee", cost: 10 }
    ]
    },
  3. Update the text to match the options you want to come up in your food helper tool (examples in red). Make sure to retain all quotes, commas, brackets, and other script items.
    {
    name: "Seoul BBQ",
    mileage: 5,
    dishes: [
    { name: "Bibimbap and Kimchi", cost: 29 },
    { name: "Kimchi Fried Rice", cost: 19 }
    ]
    },
  4. Note that the last item in the lists does not have a comma after the end bracket. Lists = Restaurant list and the Dish list within each restaurant.
  5. I have it set to show 3 random items. To update this, find where the comment says "Shuffle and pick up to 3" and update to your preferred amount.
    // Shuffle and pick up to 3
    const shuffled = [...filtered].sort(() => 0.5 - Math.random());
    const selected = shuffled.slice(0, 3);
  6. I have it set to show 5 historical items. To update this, find where the comment says "Keep last 5 in history" and update to your preferred amount.
    // Keep last 5 in history
    history = history.slice(0, 5);
  7. That's it! The rest of the code in the other files make the tool run properly (put the 3 core files in the same folder or update the HTML path to the CSS/JS files if you put them in different folders).

Adjustments and Customization

Unfortunately I cannot provide further support, I only learned what I needed to know to create this for my needs.

You're free to take the base script and improve it for your purposes! If you share your update, I'd appreciate a link back for getting it started, but no need to do that if you make significant updates to the code.

If you want to learn JavaScript, I used a few resources to piece this together, and they may help get you started. (I also had some previous knowledge editing code, so keep that in mind: I wasn't starting from scratch.)

Full disclosure: I did not go through every page in these links. I cherry picked what I needed to know.