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

              
                <p id="output-age"></p>
<p id="output-NoP"></p>
              
            
!

CSS

              
                
              
            
!

JS

              
                $(function(){

  var array = {'item':[
                {'name':'Aさん','age':'30才','iPhone':''},
                {'name':'Bさん','age':'31歳','iPhone':''},
                {'name':'Cさん','age':'32さい','iPhone':'true'},
                {'name':'Dさん','age':'33さい','iPhone':'true'},
                {'name':'Eさん','age':'34さい','iPhone':''}
              ]};

  var iPhoneTrueAgeSum = 0;//iPhone持ってる人の年齢合計
  var numberOfPeople = 0;//iPhone持ってる人の数
  
  for(var i = 0; i < array.item.length; i++){//オブジェクトの数だけ実行
    var $obj = array.item[i];//配列を0から順に取り出す
    var objAge = $obj.age;
    var objAgeNum = Number(objAge.replace(/[^-^0-9^\.]/g,""));//年齢を数字に
    
    if($obj.iPhone == 'true' && objAgeNum >= 32){//iPhoneを持っていて32歳以上の人
      iPhoneTrueAgeSum = iPhoneTrueAgeSum + objAgeNum;//if文の条件に合った人の年齢合計
      numberOfPeople++;//if文の条件に合った人の人数加算
      
      console.log('iPhone持ってる人の年齢の合計 '+iPhoneTrueAgeSum);
      $('#output-age').text('iPhone持ってる人の年齢の合計 '+iPhoneTrueAgeSum);
      
      console.log('iPhone持ってる人の人数 '+numberOfPeople+'人');
      $('#output-NoP').text('iPhone持ってる人の人数 '+numberOfPeople+'人');
    }
  }
  
});
              
            
!
999px

Console