Simple Calculator_Freecodecamp
How do I make an simple calculator_freecodecamp?
What is a simple calculator_freecodecamp? How do you make a simple calculator_freecodecamp? This script and codes were developed by Shikun Ke on 28 November 2022, Monday.
Simple Calculator_Freecodecamp - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Simple Calculator_Freecodecamp</title> <link rel='stylesheet prefetch' href='http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <body>
<div class="container">
<div class="calculator text-center"> <p id="demo" class="display"></p> <div class="control-penal"> <div class="row"> <button text="AC" class="btn btn-danger" onclick="clear()">AC</button> <button class="btn btn-danger" onclick="clear()">CE</button> <button class="btn btn-primary" value="%" onclick="getOperation(this.value)">%</button> <button class="btn btn-primary" value="/" onclick="getOperation(this.value)">÷</button> </div> <div class="row"> <button class="btn" value="7"onclick="getNumber(this.value)">7</button> <button class="btn" value="8"onclick="getNumber(this.value)">8</button> <button class="btn" value="9"onclick="getNumber(this.value)">9</button> <button class="btn btn-primary" value="*" onclick="getOperation(this.value)">X</button> </div> <div class="row"> <button class="btn" value="4"onclick="getNumber(this.value)">4</button> <button class="btn" onclick="getNumber(this.value)" value="5">5</button> <button class="btn" value="6" onclick="getNumber(this.value)">6</button> <button class="btn btn-primary" value="-" onclick="getOperation(this.value)">—</button> </div> <div class="row"> <button class="btn" value="1" onclick="getNumber(this.value)">1</button> <button class="btn" value="2"onclick="getNumber(this.value)">2</button> <button class="btn" value="3"onclick="getNumber(this.value)">3</button> <button class="btn btn-primary" value="+" onclick="getOperation(this.value)">+</button> </div> <div class="row"> <button class="btn" value="0" onclick="getNumber(this.value)">0</button> <button class="btn" value="." onclick="getNumber(this.value)">.</button> <button class="btn btn-primary btn-equal" onclick="equal()">=</button> </div> </body> <p id="test"></p> <script src="js/index.js"></script>
</body>
</html>
Simple Calculator_Freecodecamp - Script Codes CSS Codes
.display{ margin-left:auto; margin-right:auto; border:2px solid #a1a1a1; height:40px; margin-top:30px; margin-bottom:20px; background:#dddddd; width:300px; font-size:20px;
}
.btn{ width:60px; margin-right:7.5px; margin-left:7.5px;
}
.btn-equal{ width:138px;
}
.row{ margin:6px;
}
Simple Calculator_Freecodecamp - Script Codes JS Codes
var store = [];
var result = 0;
var opera = '';
var string = '';
function getNumber(value){ string += value; document.getElementById("demo").innerHTML = string;
}
function getOperation(operation){ store.push(string); string = ''; opera = operation;
}
function equal(){ store.push(string); if(store.length==1) result = Number(store[0]); else { var value1 = Number(store[store.length-2]); var value2 = Number(store[store.length-1]); if(opera=="+") result = value1+value2; else if(opera=="-") result = value1-value2; else if(opera=="*") result = value1*value2; else if(opera=="/") result = value1/value2; else if(opera=="%") result = value1%value2; } document.getElementById("demo").innerHTML = result; string = ''; store = [];
}
function clear(){ string = ''; store = []; result = 0; document.getElementById("demo").innerHTML = result;
}
Developer | Shikun Ke |
Username | BarryKe |
Uploaded | November 28, 2022 |
Rating | 3 |
Size | 2,283 Kb |
Views | 8,096 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
25min countdown | 2,276 Kb |
Random Quote Machine_FreeCodeCamp | 3,312 Kb |
Cash Register Drawer | 3,124 Kb |
Main page display | 4,562 Kb |
A Pen by Shikun Ke | 3,027 Kb |
Portfolio Website | 3,215 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
CSS Link Zoom On Click | Bryce | 1,960 Kb |
Basic 3D Fullscreen Transition | Apetrov | 3,270 Kb |
Very Simple Slider | Doodlemarks | 2,682 Kb |
A Pen by Tosh | Panev | 2,586 Kb |
A vuejs widget | Chrgl86 | 2,869 Kb |
Glitchy Text Effect | Kescoe | 2,208 Kb |
A Pen by Theun | Tjoen | 6,152 Kb |
Zip Button test | Lje7462 | 1,932 Kb |
CSS Bot Confusion | Jpod | 3,456 Kb |
CSS Tooltips | Darylldoyle | 2,599 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!