Last active
June 13, 2020 23:53
-
-
Save marcosrivasr/c3a7b2023890ec1c97a01588ac5d174e to your computer and use it in GitHub Desktop.
Archivos iniciales para el ejercicio de Webpack 🚀
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function division(number1, number2){ | |
return parseInt(number1) / parseInt(number2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Tutorial para usar Webpack</title> | |
<link rel="stylesheet" href="main.css"> | |
</head> | |
<body> | |
<div id="container"> | |
<label for="number1">Número 1</label> | |
<input type="text" id='n1'> | |
<label for="number1">Número 2</label> | |
<input type="text" id='n2'> | |
<label for="op">Operación</label> | |
<select name="op" id="op"> | |
<option value="+">Suma</option> | |
<option value="-">Resta</option> | |
<option value="*">Multiplicación</option> | |
<option value="/">División</option> | |
</select> | |
<button id="btn">Resolver</button> | |
<code id="res"></code> | |
</div> | |
<script src="sum.js"></script> | |
<script src="substraction.js"></script> | |
<script src="multiplication.js"></script> | |
<script src="division.js"></script> | |
<script src="index.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const btn = document.querySelector('#btn'); | |
const n1 = document.querySelector('#n1'); | |
const n2 = document.querySelector('#n2'); | |
const op = document.querySelector('#op'); | |
const res = document.querySelector('#res'); | |
btn.addEventListener('click', e =>{ | |
switch(op.value){ | |
case '+': | |
res.textContent = sum(n1.value, n2.value); | |
break; | |
case '-': | |
res.textContent = substraction(n1.value, n2.value); | |
break; | |
case '*': | |
res.textContent = multiplication(n1.value, n2.value); | |
break; | |
case '/': | |
res.textContent = division(n1.value, n2.value); | |
break; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import url('https://fonts.googleapis.com/css2?family=Raleway:wght@500&display=swap'); | |
:root{ | |
font-size: 16px; | |
} | |
*{ | |
box-sizing: border-box; | |
} | |
body{ | |
background-color: rgb(100, 30, 40); | |
} | |
#container{ | |
background-color: white; | |
font-family: 'Raleway', sans-serif; | |
width: 400px; | |
margin: 0 auto; | |
padding:1rem; | |
} | |
#container input, | |
#container label, | |
#container button{ | |
display: block; | |
font-size: 1.5rem; | |
} | |
#container label{ | |
padding: 0.5rem 0; | |
} | |
#container input, #container select{ | |
width: 100%; | |
padding: 1rem; | |
} | |
#container button{ | |
margin: 1rem auto; | |
} | |
#container #res{ | |
background-color: #ddd; | |
padding: 1rem; | |
display: block; | |
width: 100%; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function multiplication(number1, number2){ | |
return parseInt(number1) * parseInt(number2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function substraction(number1, number2){ | |
return parseInt(number1) - parseInt(number2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sum(number1, number2){ | |
return parseInt(number1) + parseInt(number2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment