Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <body onload="myFunction()">
  <div id="card">
    <div id="head">
      <p>№ of exercises: <output name="numberOutputName" id="numberOutputId">6</output></p>
      <input id="userInput" type="range" placeholder="6" value="6" step="1" min="1" max=""
        oninput="numberOutputId.value = userInput.value">
      <p>
        <button class="btn" onclick="myFunction()">Create new workout </button>
      </p>
    </div>
    <ol id="exercises"></ol>
  </div>
</body>
              
            
!

CSS

              
                body {  
    font-family: Arial, Helvetica, sans-serif;
    font-size: 18px;
}

#card {
    max-width: 20rem;
    margin: auto;
    padding: 30px;
  }

  #head {
    text-align: center;
    border-bottom: solid 2px var(--accent);
  }

  #exercises {
    list-style-position: outside;
    line-height: 1.7rem;
    padding-left: 10%;
    margin-top: 40px;
  }

.btn {
  border-radius: 5px;
  text-transform: uppercase;
  color: #ffffff;
  font-size: 0.8rem;
  background: #0075FF;
  padding: 15px 15px 15px 15px;
  text-decoration: none;
  border-style: none;
}

.btn:hover {
  filter: brightness(125%);
  text-decoration: none;
  cursor: pointer;
}
              
            
!

JS

              
                // get the slider value
    function getNumber(){
        let input = document.getElementById("userInput").value;
      return input
    }

    // triggered by the main button: set the number of exercises to "n"
    function myFunction() {
      let n = getNumber()

      // clear the list of any existing exercises
      document.getElementById("exercises").innerHTML = "";

      // define the array
      const all_exercises = [
        [" air squats ×40", "back squats ×20", "front squats ×20"], // alternatives group
        [" skip ×100"],
        [" burpees ×20"],
        [" row 500m", " row 250m"], // alternatives group
        [" pull-ups ×10", " ring pull-ups ×10", " pike ring pull-ups ×5", " finger board pull-ups ×10"], // alternatives group
        [" sit-ups ×35"],
        [" push-ups ×25", " ring push-ups ×10"], // alternatives group
        [" lunges ×30"],
        [" curls ×15"],
        [" ring rows ×12"],
        [" assisted ring dips ×10", " bench dips ×25"], // alternatives group
        [" power clean ×25", " power clean & jerk ×15", " power snatch ×10"], // alternatives group
        [" hanging leg raises ×20"],
        [" bench press ×10"],
        [" calf raises ×20"],
        [" plank 40s"],
        [" kettlebell swings ×20"],
        [" kettlebell push-press ×20"],
      ]

      // Set the max value of the slider (with id=userInput) to the # of elements in the array
      document.getElementById("userInput").setAttribute('max', all_exercises.length);

      // shuffle the full array
      function shuffleArray(array) {
        for (let i = array.length - 1; i > 0; i--) {
          const j = Math.floor(Math.random() * (i + 1));
          [array[i], array[j]] = [array[j], array[i]];
        }
      }

// pull out the first n values from the shuffled array and display as ordered list
shuffleArray(all_exercises);
    all_exercises.slice(0,n).forEach(e => {
      shuffleArray(e); // shuffle the nested array
        exercises.innerHTML =  exercises.innerHTML + '<li>' + e[0] + '</li>' ; // choose the first element using e[0]
    });
    }
              
            
!
999px

Console