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.






                var shops = [{
    captain: "Tim",
    chicken: 150,
    coke: 200,
    fries: 70,
    set: 99,
    captain: "Min",
    chicken: 99,
    coke: 77,
    fries: 55,
    captain: "Mike",
    chicken: 105,
    coke: 111,
    fries: 75,
    set: 130,

var shopsTotal = shops.length; //先抓取店面的資料
console.log(shopsTotal); //結果會得到 3
var cokeTotal = 0; //先預設數量為 0
for (var i = 0 ; i < shopsTotal ; i++) { //從第一個開始迴圈;在店家數以內條件以內;加總
  cokeTotal+= shops[i].coke; //"+=" 要寫在一起,不能空白

console.log("今年的可樂銷售額為: " + cokeTotal); //結果會得到 今年的可樂銷售額為: 388