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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <div class="div-container"></div>

<p id="data"></p>
<p id="goals"></p>
              
            
!

CSS

              
                body {
  text-align: center;
  width: 50%;
  background-color: pink;
  margin: 0 auto;
  font-family: Arial;
  font-size: 18px;
}
              
            
!

JS

              
                var testApp = {};
testApp.test = function() {
    testApp.color = 'green';
}

testApp.testy = function() {
  // This logs the variable from the above function fine
    console.log(testApp.color);
} 
testApp.test();
testApp.testy();

/***************/

var app = {};

app.getData = function() {
app.arrayOfObjects = {};
  console.log(app.arrayOfObjects);
$.ajax({
  headers: { 'X-Auth-Token': '86d5dd33e1694c99b30be68b74954960' },
  url: 'http://api.football-data.org/v1/teams/322/fixtures',
  dataType: 'json',
  type: 'GET',
}).done(function(response) {
  // do something with the response, e.g. isolate the id of a linked resource      
app.arrayOfObjects = response.fixtures;
// This logs the object fine
console.log(app.arrayOfObjects);
});
}


app.outputScores = function() {
  // Why does this log undefined yet the one above logs the object?
console.log(app.arrayOfObjects);

  //console.log(app.arrayOfObjects);
  for (var i = 0; i < app.arrayOfObjects.length; i++) {
  document.write(app.arrayOfObjects[i].homeTeamName + ' ' + app.arrayOfObjects[i].result.goalsHomeTeam + ' - ' + app.arrayOfObjects[i].result.goalsAwayTeam + ' ' + app.arrayOfObjects[i].awayTeamName + '<br>')
}
 
};
app.getData();
app.outputScores();




/*
function test() {
console.log(app.arrayOfObjects);
};
test();
*/


              
            
!
999px

Console