cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              .container
	h1 Math
	b Let's generate a list of number between 0 and 5
	p(var="list")
	b Now, let's do the sum of this list
	p(var="sum")
	b We could also find the average of this list
	p(var="average")
	b ... and the median
	p(var="median")
	b But we can also do super cool things <br>
		| such as predicting a logical sequence.
	p Let's say we have a sequence of 3 numbers We can predict what would be the fourth number, and what is the function.
	input(type="text" target="sequence" placeholder="3, 5, 7")
	p(var="logic")
	
	h2 Like what you see? Learn DisplayJS!
            
          
!
            
              // declaring init var
var $ = new DisplayJS(window);

var list = $.range(5)

var sum = $.sum(list)

var sequence = '3, 5, 7'

var logicSeq = [3, 5, 7]

array = {}
	
for(let i in $.range(logicSeq.length - 1)) {
	array[parseInt(i) + 1] = logicSeq[i]
}
logic = $.predict(array, logicSeq.length + 1, true)

var average = $.average(list)

var median = $.median(list)

$.var()

$.target(function () {
	logicSeq = eval(`[${sequence}]`)
	
	array = {}
	
	for(let i in $.range(logicSeq.length - 1)) {
		array[parseInt(i) + 1] = logicSeq[i]
	}
	logic = $.predict(array, logicSeq.length + 1, true)
	
	$.var()
})
            
          
!
999px
Loading ..................

Console