function operation(input A, inputB){
return ;
}
$("button").click(function(){
var inputA = $("#inputA").val();
var inputB = $("#inputB").val();
operation(inputA, inputB);
});
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>ScriptEd Robot 1</title> | |
<link href="https://fonts.googleapis.com/css?family=Space+Mono|Audiowide" rel="stylesheet"> | |
</head> | |
<body> | |
<h1> ScriptEd Robot</h1> | |
<img src="https://images-mm.s3.amazonaws.com/Futurama_Bender_Face_Gray_Shirt_POP.jpg"> | |
<div> | |
<input id="inputA" placeholder="A"> | |
<input id="inputB" placeholder="B"> | |
</div> | |
<br> | |
<div> | |
<button id="add">A + B</button> | |
<!-- Write all of your other buttons here --> | |
</div> | |
<br> | |
<div> | |
Answer = <span id="result"></span> | |
</div> | |
</body> | |
</html> |
{"enabledLibraries":["jquery"],"hiddenUIComponents":["console","editor.css"]} |
///////////////////////////////////// | |
// Define your robot functions | |
///////////////////////////////////// | |
// Add (+) | |
function add(inputA, inputB) { | |
return parseInt(inputA) + parseInt(inputB); | |
} | |
// Subtract (-) | |
// Multiply (*) | |
// Divide (/) | |
// (A + B) / 2 | |
// Say hello | |
///////////////////////////////////// | |
// Define your click handlers | |
///////////////////////////////////// | |
// Add (+) | |
$('#add').click(function() { | |
// What do you want to do when the "+" button is clicked? | |
var inputA = $("#inputA").val(); | |
var inputB = $("#inputB").val(); | |
var result = add(inputA, inputB); | |
$("#result").text(result); | |
}); | |
// Subtract (-) | |
// Multiply (*) | |
// Divide (/) | |
// (A + B) / 2 | |
// Say hello | |
img { | |
height:180px; | |
} | |
h1{ | |
font-family: 'Audiowide', cursive; | |
font-size:48px; | |
margin:0px; | |
} | |
body{ | |
text-align:center; | |
} | |
input { | |
font-size:12px; | |
text-align: center; | |
} | |
div { | |
margin-top:3px; | |
font-family: 'Space Mono', monospace; | |
font-size: 24px; | |
} |