Community » Forum » Feedback » Developer Community

spacetinker
Businessman   VIP
it isn't bringing anything up it might be that im on a school computer that i can't access it i'll look at it later
masterplayer833
Businessman   VIP
I am on a schoolcomputer as well. I will check again.
masterplayer833
Businessman   VIP
Fixed:
<html>
<body>
<p>
this is a calculator simply enter the first number here
</p>
<input type="number" id="first"></input>
</body>
<p>
select the operation here
</p>
<button onclick="add()">+</button>
<button onclick="subtract()">-</button>
<button onclick="multiply()">*</button>
<button onclick="divide()">/</button>
<p>
put the seconed number here
</p>
<input type="number" id="seconed"></input>

<button onclick="run()">
perform
</button>
<button id="final" disabled="true">
this is where the answer is
</button>
</html>
<script>
var oper = 1;
function add(){
oper = 1;
}
function subtract(){
oper = 2;
}
function multiply(){
oper = 3;
}
function divide(){
oper = 4;
}
function run(){
var onenumber = document.getElementById("first").value
var twonumber = document.getElementById("seconed").value
if (oper == 1) {
// must use to string or else thinks you are concatenationg. So if #1= 3 and #2=4 it returns 34
var finalnum = Number(onenumber) + Number(twonumber)
}
if (oper == 2) {
var finalnum = onenumber - twonumber
}
if (oper == 3) {
var finalnum = onenumber * twonumber
}
if (oper == 4) {
var finalnum = onenumber / twonumber
}
document.getElementById("final").innerHTML = finalnum;
}
</script>
spacetinker
Businessman   VIP
thanks i looked through it and found the problem i can't believe i forgot the parentheses around the operators
spacetinker
Businessman   VIP
what should i try to make next?
spacetinker
Businessman   VIP
should i try to make a game?
like a text game with a virtual buisness or a dungeon thing?
masterplayer833
Businessman   VIP
Whatever you want, though for game, take a look at p5 and p5play. I made a game using p5play. You can check out my code: Rolling Ball. Though for game dev I use unity.
masterplayer833
Businessman   VIP
Whatever you want, though for game, take a look at p5 and p5play. I made a game using p5play. You can check out my code: Rolling Ball. Though for game dev I use unity.
masterplayer833
Businessman   VIP
Unity is not HTML; it is C#
masterplayer833
Businessman   VIP
So, what is your next project going to be?
First ... 9 10 11 12 13 ... Last