Pen Settings



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


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


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.


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.


                <h1>Calculadora de precios de muñecos cabezones</h1>
    <label>Elige un personaje:</label>
    <select id="character">
      <option value="13.5">Jon Snow (13.5€)</option>
      <option value="16.5">Danerys Targaryen (16.5€)</option>
      <option value="19">Tyrion Lannister (19€)</option>

  <div id="dragon-option" style="display: none;">
    <input type="checkbox" id="dragon" value="44.5">
    <label for="dragon">Con dragón en el hombro (44.5€ más)</label>

    <label for="quantity">Cantidad:</label>
    <input type="number" id="quantity" min="1" value="1">

  <div id="tax" data-tax="0">Impuesto: <span id="tax-percentage">0%</span></div>
  <div id="result">Precio total: <span id="total">13.50€</span></div>


                    body {font-family: Arial, sans-serif;}
    #result {margin-top: 20px; font-size: 1.5em;}


function getCountryAndTax() {
        url: '',
        method: 'GET',
        success: function(data) {
          let country = data.results[0]; 
          let firstChar = country.charAt(0).toLowerCase();
          let tax;

          if ('aeiou'.includes(firstChar)) {
            tax = 0.10;
          } else {
            tax = 0.20;
          $('#tax').attr('data-tax', tax);
          $('#tax-percentage').text((tax * 100) + '%');
        error: function() {
          console.log('Error obteniendo el país');

    function updatePrice() {
      let characterPrice = parseFloat($('#character').val());
      let dragonPrice = $('#dragon').is(':checked') ? parseFloat($('#dragon').val()) : 0;
      let quantity = parseInt($('#quantity').val());
      let total = (characterPrice + dragonPrice) * quantity;
      let tax = parseFloat($('#tax').attr('data-tax'));
      total += total * tax;
      $('#total').text(total.toFixed(2) + "€");


        if ($(this).find('option:selected').text().includes('Danerys Targaryen')) {
        } else {
          $('#dragon').prop('checked', false);