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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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>Математическая задача:</h1> 
<p>3 человека пошли за покупками. Каждый следующий потратил в 5 раз больше предыдущего.</p>
<p>Сколько потратил каждый, если все вместе заплатили <strong class="red">24 грн 80 коп</strong>? <strong class="green">186 грн</strong>?  <strong class="blue">319 грн 30 коп</strong>?</p>
<h2>Покупка одного человека (возврат 1 значения из функции)</h2>
              
            
!

CSS

              
                body {
  font-family: sans-serif;
  margin: 30px 5%;
}
.red {
  color: red;
}
.green {
  color: green;
}
.blue {
  color: blue
}

              
            
!

JS

              
                function oneBuyThings(sum){
  return sum/(1+5*1+5*5);
}
let res1 = oneBuyThings(24.80);
let res2 = oneBuyThings(319.30);
document.write(`<p>Один человек купил на сумму ${res1} грн, второй - на ${res1*5} грн, третий - на ${res1*25} грн.</p>`);
document.write(`<p>Один человек купил на сумму ${res2} грн, второй - на ${res2*5} грн, третий - на ${res2*25} грн.</p>`);

function buyThings(sum, currency='грн'){
  let first = sum/31;
  let second = 5*first;
  let third = 5*second;
  return {first, second, third};
}
let res3 =  buyThings(319.30);
console.log(res3); //{first: 10.3, second: 51.5, third: 257.5}
document.write("<h2>Покупка нескольких человек (возврат объекта из функции)</h2>");
document.write(`<p>Один человек купил на сумму ${ res3.first }, второй - на сумму - ${ res3.second } грн., третий потратил ${ res3.third }грн.</p>`);

let res4 =  buyThings(186);
console.log(res4); //{first: 6, second: 30, third: 150}
document.write(`<p>Один человек купил на сумму ${ res4.first } грн., второй - на сумму - ${ res4.second } грн., третий потратил ${ res4.third } грн.</p>`);
              
            
!
999px

Console