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.


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 lang="ja">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <script src="[email protected]"></script>
  <div id="root"></div>




                const en = 'He wants to be independent of his parents.'
const RootComponent = {
  data () { return {
    origin: en,
    text: setData(),    //初期設定
    p: [],              //何番目まで答えたかの位置
    showBackward: true, //「戻る」ボタンの表示・非表示
    message: ''         //メッセージの本文
  template: `
      <span v-for="word in text.words">
        {{word+" "}}
        v-for="(option, index) in text.opt"
      <button v-show="showBackward" @click="backward">戻る</button>
  methods: {
    input(index) {
      this.text.optShow[index] = false;  //押されたボタンを非表示に
      this.text.words[this.text.mask[this.p.length]] = this.text.opt[index];
      this.text.record.push(index);   //押されたボタンの番号を記録
      if(this.text.optMask[index] == this.text.mask[this.p.length]) { 
        this.p.push('correct');   //正解なら配列にcorrectを加える
      } else { 
        this.p.push('incorrect'); //不正解なら配列にincorrectを加える
      if(this.p.length == this.text.mask.length) {
        this.showBackward = false;  //「戻る」ボタンを非表示にする
        if(this.p.every(value => value == 'correct')) {
          this.message = 'すべて正解です。';
        } else {
          this.message = '誤りがあります。';
    backward() {
      if(this.p.length > 0) {
        this.p.pop();   //配列の最後の要素を削除して一つ戻る
        this.text.words[this.text.mask[this.p.length]] = ' ____ ';
        this.text.optShow[this.text.record.pop()] = true;
function setData() {
  let obj = {
    words: en.split(' '),   //本文を単語ごとに分割
    record: [],             //ボタンを押した順番の記録
    mask: [],               //マスクする単語の位置
    opt: [],                //選択肢の文字列
    optMask: [],            //選択肢が表す単語の位置
    optShow: []             //ボタンの表示・非表示
  let n = Array.from(Array(obj.words.length).keys()); //連番の配列
  for(let i = 0; i < 100; i++) {
    let a = Math.floor(Math.random() * n.length);
    let b = Math.floor(Math.random() * n.length);
    [n[a], n[b]] = [n[b], n[a]];
  let amount = 1 + Math.round(obj.words.length * 0.25);
  for(let i = 0; i < amount; i++) {
    obj.mask.push(n[i]);            //マスクする単語の位置を追加
    obj.opt.push(obj.words[n[i]]);  //選択肢の文字列を追加
    obj.optMask.push(n[i]);         //選択肢が表す単語の位置を追加
    obj.optShow.push('true');       //ボタンの表示を追加
  obj.mask.sort((a, b) => a - b); //昇順に並べ替え
  for(let i = 0; i < obj.opt.length; i++) {
    obj.words[obj.mask[i]] = ' ____ ';
  return obj;
const app = Vue.createApp(RootComponent);