css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <h1> FreeCodeCamp Project </h1> 
  <h2> Calculator </h>
<div>
<div id="sep"> </div>
    <div class="fixed-size-square">
      <div>
      <input type="text" name="calcInputs" id="inputs">
      </div>
      <div class = "first">
<button onclick = "clearAll()" id = "AC" class = "btn btn-primary"> AC </button>
 <button onclick= "clearLast()" id = "C" class = "btn btn-primary"> C </button>
  <button onclick = "div()" id = "%" class = "btn btn-primary"> ÷ </button>
   <button onclick = "multiply()"id = "x" class = "btn btn-primary"> X </button>
      </div>
<div>
  <button onclick="insNum(7)" class = "btn btn-primary"> 7 </button>
    <button onclick="insNum(8)"class = "btn btn-primary"> 8 </button>
    <button onclick="insNum(9)"class = "btn btn-primary"> 9 </button>
  <button onclick = "minus()" class = "btn btn-primary"> - </button>
  </div>
  <div>
  <button onclick="insNum(4)"class = "btn btn-primary"> 4 </button>
    <button onclick="insNum(5)"class = "btn btn-primary"> 5 </button>
    <button onclick="insNum(6)" class = "btn btn-primary"> 6 </button>
    <button onclick = "sum()" class = "btn btn-primary"> + </button>
    </div>
    <div id="cuarta">
  <button onclick = "insNum(1)" class = "btn btn-primary"> 1 </button>
    <button onclick="insNum(2)"class = "btn btn-primary"> 2 </button>
    <button onclick="insNum(3)"class = "btn btn-primary"> 3 </button>
      </button>
    <button onclick="gimmeResult()"id = "equal" class = "btn btn-primary"> = </button>
      <div>
            <button  onclick= "insNum(0)" id = "zero" class = "btn btn-primary"> 0 </button>
    <button onclick = "insPoint()" id ="." class = "btn btn-primary"> . </button>
      </div>
  </div>
        </div>
  <div>
    <div id="sep"> </div>
  <fotter id "fjd"> <a> Written and Coded by <a href= "https://codepen.io/francodanussi"> FJD </fotter>
    
    </div>
  
  
  
 
      
 
        
 
 
  
            
          
!
            
              @import url('https://fonts.googleapis.com/css?family=Roboto');

#sep{
  height: 50px;
}

h1, h2{
  font-family: Roboto;
}

body{
  background-color: #556B2F;
}

#C, #AC {
  background-color:red;
  color: white;
}

.btn{
  border: 2px solid black;
  width: 45px;
  height: 40px;
  font-size: 20px;
  cursor: pointer;
}

.btn {
  background: #fafafa;
  background-image: -webkit-linear-gradient(top, #fafafa, #79797a);
  background-image: -moz-linear-gradient(top, #fafafa, #79797a);
  background-image: -ms-linear-gradient(top, #fafafa, #79797a);
  background-image: -o-linear-gradient(top, #fafafa, #79797a);
  background-image: linear-gradient(to bottom, #fafafa, #79797a);
  -webkit-border-radius: 16;
  -moz-border-radius: 16;
  border-radius: 16px;
  font-family: Arial;
  border: solid #d1d1d1 3px;
  text-decoration: none;
}

.btn:hover {
  background: #696a6b;
  background-image: -webkit-linear-gradient(top, #696a6b, #383838);
  background-image: -moz-linear-gradient(top, #696a6b, #383838);
  background-image: -ms-linear-gradient(top, #696a6b, #383838);
  background-image: -o-linear-gradient(top, #696a6b, #383838);
  background-image: linear-gradient(to bottom, #696a6b, #383838);
  text-decoration: none;
}

#inputs{
  margin-top: 15px;
  height: 40px;
  width: 195px;
  border-radius:10px;
  font-family: Roboto;
  font-size: 20px;
}

.first{
  margin-top: 10px;
}


body {
  text-align: center;
} 

#zero{
  width: 100px;

}

#.{
  width: 
}

#equal{
  position:absolute;
  height: 80px;
  margin-left: 5px;
  margin-top: 2px;
}

#cuarta{
  margin-left: -50px;
}

.fixed-size-square {
    margin-top: 40px;
    margin: 0 auto;
    width: 100px; /* Or some other width */
    display: table;
    width: 300px;
    height: 300px;
    background: grey;
    border-radius: 13px;
}





            
          
!
            
              var num = "";
var arrInp = [];
var str = "";
var temp = [];
var total = 0;
var last = arrInp[arrInp.length - 1];

function insNum(num) {
    arrInp.push(num);
    document.querySelector("#inputs").value = arrInp.join("");
}

function insPoint() {
    num = ".";
    insNum(num);
}

function sum() {
    arrInp.push("+");
    temp = temp.concat(arrInp);
    arrInp = [];
    document.querySelector("#inputs").value = [];
};

function minus() {
    arrInp.push("-");
    temp = temp.concat(arrInp);
     arrInp = [];
    document.querySelector("#inputs").value = [];
};

function div() {
    arrInp.push("/");
    temp = temp.concat(arrInp);
    arrInp = [];
    document.querySelector("#inputs").value = [];
};

function multiply() {
    arrInp.push("*");
    temp = temp.concat(arrInp);
    arrInp = [];
    document.querySelector("#inputs").value = [];
};

function clearLast() {
    arrInp.splice(-1, 1);
    document.querySelector("#inputs").value = arrInp.join("");
};

function clearAll() {
    arrInp = [];
    temp = [];
    document.querySelector("#inputs").value = [];
};

function gimmeResult() {
  var result = temp.concat(arrInp);
  console.log(result)
    var expReg = /(\+|\*|\/|\-)+/g
   var final = result.join("");
  console.log(final);
    var retorn = eval(final);
  console.log(retorn);
    document.querySelector("#inputs").value = retorn;
  temp = [];
  arrInp = [];
  arrInp.push(retorn);
};
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console