Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h1>Choose-a-Tron</h1>
<p>Ugh, I can't decide.</p>
<button>Choose a <span id="what"></span></button>
<h2>Options</h2>
<ul id="options"></ul>
<footer>
  <p>🙏 Thanks to <a href="https://twitter.com/GantLaborde">Gant Laborde</a> for the project idea!</p>
</footer>
              
            
!

CSS

              
                /* These are CSS Variables. If you want to change the color scheme, try a different hue between 0 and 270. The colors in the CSS will automatically update. */
:root {
  --hue: 20;
  --choice-hue: 80;
}
body {
  color: hsl(var(--hue), 85%, 10%);
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: Georgia, serif;
}
h1,
h2 {
  color: hsl(var(--hue), 85%, 40%);
  font-family: Futura, Helvetica, sans-serif;
  margin-top: 4rem;
  text-transform: uppercase;
}
button {
  background-color: hsl(var(--hue), 80%, 50%);
  border: none;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.12);
  color: white;
  cursor: pointer;
  display: inline-block;
  font-family: Futura, Helvetica, sans-serif;
  font-size: 1em;
  font-weight: 700;
  padding: 20px;
  text-transform: uppercase;
}
button:hover {
  background-color: hsl(var(--hue), 80%, 53%);
}
ul {
  margin-top: 0;
  padding: 0;
}
ul li {
  background-color: hsl(var(--hue), 80%, 90%);
  list-style: none;
  margin: 8px;
  padding: 12px 20px;
  text-align: center;
}

.choice {
  background-color: hsl(var(--choice-hue), 80%, 90%);
  color: hsl(var(--choice-hue), 80%, 20%);
  position: relative;
}
.choice:before {
  content: "👉";
  position: absolute;
  left: -17px;
  top: 3px;
  font-size: 32px;
}

a {
  color: hsl(var(--hue), 80%, 48%);
  border-bottom: 1px solid var(--pink-10);
  box-shadow: hsl(var(--hue), 80%, 90%) 0 -2px 0 0 inset;
  text-decoration: none;
}
a:hover {
  background-color: hsl(var(--hue), 80%, 92%);
  color: hsl(var(--hue), 80%, 50%);
  text-decoration: none;
}

              
            
!

JS

              
                // Defines what category we're choosing and updates the webpage with this. Customize these with your own category and items!
let what = "cocktail";
document.querySelector("#what").innerText = what;

// Defines our options to choose from
let options = [
  "Intro to Aperol",
  "Margarita",
  "Champagne cocktail",
  "Gin and soda",
  "Old fashioned",
  "Paloma",
  "Sazerac"
];
const optionsList = document.querySelector("#options");

// ********************************
// 1. Alphabetize the options list (2 points)
// ********************************
// Your code here:

// ********************************
// 2. Make the options list use title case (2 points)
// ********************************
// The first letter of each word should be capitalized. For 2 bonus points: Make it skip words like "and", "a", "the", "to", etc.
// Your code here:

// Don't code #2 past this point.
// This forEach loop renders our options in the webpage:
options.forEach((option, index) => {
  const listItem = document.createElement("li");
  listItem.innerText = option;
  listItem.id = `item-${index}`;
  optionsList.append(listItem);
});

// Declares a variable equal to our button
const button = document.querySelector("button");

// ********************************
// 3. Write a function that accepts a max numbers as a parameter and returns a random number between 0 and that number. (2 points)
// ********************************
// Your code here:

// ********************************
// 4. Make it so that when someone clicks the "choose" button, a random item in the list gets highlighted with a different background color. (4 points)
// ********************************
// Your code here:

// ********************************
// 5. (Optional Bonus) Oops! Refactor your code to not update the background color directly but to instead add/remove the class "choice" so that each time the button is clicked, the previously chosen item returns to normal, and a new item is selected (2 bonus points).
// ********************************
// Your code here:

              
            
!
999px

Console