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.

    <title> Pactice 2</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="main.css">
    <link href="https://fonts.googleapis.com/css?family=Orbitron" rel="stylesheet">
    <script src="practice2.js"></script>
    <div id="container">
        <div id="screen">
            <input type="text" id="display" disabled style="height:50px; width:260px">

            <p id="result"></p>
<div id="keypad">  
    <input type="button" value="&#8730;" onclick="sqrtNum()">
    <input type="button" value="CE" onclick="clearAll()">
    <input type="button" value="^" onclick="storeNum('^')">
    <input type="button" value="+" onclick="storeNum('+')">   
    <input type="button" value="9" onclick="display('9')">
    <input type="button" value="8" onclick="display('8')">
    <input type="button" value="7" onclick="display('7')">
    <input type="button" value="-" onclick="storeNum('-')">   
    <input type="button" value="6" onclick="display('6')">
    <input type="button" value="5" onclick="display('5')">
    <input type="button" value="4" onclick="display('4')">
    <input type="button" value="*" onclick="storeNum('*')">
    <input type="button" value="3" onclick="display('3')">
    <input type="button" value="2" onclick="display('2')">
    <input type="button" value="1" onclick="display('1')">
    <input type="button" value="/" onclick="storeNum('/')">
    <input type="button"  value="0" onclick="display('0')">
    <input type="button" value="." onclick="display('.')">
    <input id="equal" type="button" value="=" onclick="mathCalculation()" style="height:50px; width:115px">

              * {
    margin: 0;
    padding: 0;

body {
    width: 100%;
     background: #30454c;

#container {
    margin: 0 auto;
    margin-top: 90px;
    height: auto;
    background: #150149;
    position: relative;
    padding: 0;
    padding-bottom: 50px;
    padding-top: 50px;

#screen {
    width: 52%;
    height: 30px;
    margin:  0 auto;
    margin-bottom: 50px;
    padding-right: 56px;
    background-color: aliceblue;

#keypad {
    margin: 0 auto;
    margin-top: 20px;
    width: 80%;
    height: auto;

#keypad input {
    text-align: center;
    font-size: 15px;
    padding: 15px;
    margin: 5px;
    background-color: darkgrey;

#display {
    text-align: right;
    font-size: 40px;
    font-family: 'Orbitron', sans-serif;

              var prevNum = "";
var currNum = "";
var setNumber;
var resultNum;
var operator;
var evaluation;

 function clearAll() {
    var screen = document.getElementById("display");
    prevNum = "";
    currNum = "";
    screen.value = "0";
    screen.setAttribute("value", resultNum);

function display(x){
        var screen = document.getElementById("display");
        currNum += x;
        screen.value = currNum;  

function mathCalculation(){
    var screen = document.getElementById("display");
    //converts string to numbr
    prevNum = parseFloat(prevNum);
    currNum = parseFloat(currNum);
    if(operator === "^") {
        resultNum = Math.pow(prevNum,currNum);
        screen.value = resultNum;
    else {
    evaluation = prevNum + operator + currNum;
    resultNum = eval(evaluation);
    currNum = resultNum;
    screen.value = resultNum;

//store number
function storeNum(x) {
    operator = x;
    prevNum = currNum;
    currNum = "";

function sqrtNum() {
    var screen = document.getElementById("display");
    currNum = Math.sqrt(currNum);
    screen.value = currNum;
Loading ..................