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.

              <h1>JavaScript Random Numbers</h1>
<p id="result1">Result...</p>
<h2>From 0 to specific number</h2>
<p id="result2">Result...</p>
<h2>Removing decimals</h2>
<p id="result3">Result...</p>
<h2>Random between two numbers (between 5 and 10)</h2>
<p id="result4">Result...</p>
<h2>Random between two between 5 and 10 (included 10)</h2>
<p id="result5">Result...</p>
              //Basic Random
var random1 = Math.random();
document.getElementById("result1").innerHTML = random1;
//From 0 to specific number
var random2 = Math.random() * 10;
document.getElementById("result2").innerHTML = random2;
//Removing decimals
var random3 = Math.floor(Math.random() * 10);
document.getElementById("result3").innerHTML = random3;
//Random between 5 and 10
var random4 = Math.floor(Math.random() * 5) + 5;
document.getElementById("result4").innerHTML = random4;
//Random between 5 and 10 (included 10)
var random5 = Math.floor(Math.random() * 5) + 6;
document.getElementById("result5").innerHTML = random5;
Loading ..................