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.


<p>HP:<span id="hp"><span></p>
<button onclick="kaifuku()">やくそう</button>
<p id="message"></p>




                // 初期HPを書き込む
const _hp = document.getElementById("hp");
_hp.innerText = 50;

// やくそうボタンが押された時の処理
function kaifuku() {
    // 23〜30の間のランダムな数字を選ぶ
    const healPoint = Math.floor(Math.random() * (30 + 1 - 23)) + 23;

    // メッセージを表示する
    ).innerText = `ゆうしゃは${healPoint}ポイント回復した。`;

    // HPを書き換える
    let old_hp = document.getElementById("hp").innerText; // 元のHPを取得する
    old_hp = Number(old_hp); // 数値に変換する
    let new_hp = old_hp + healPoint; // 加算する
    _hp.innerText = new_hp;