Last active
March 20, 2024 19:33
-
-
Save aaizemberg/d133b84901873b837ea7a6de96a4cfc2 to your computer and use it in GitHub Desktop.
Dame tu DNI y te estimo la edad
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> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>Dame tu DNI y te estimo la edad</title> | |
<script src="https://d3js.org/d3.v7.min.js"></script> | |
</head> | |
<body> | |
<input type="number" id="dni"> | |
<h4><div id="edad"></div></h4> | |
<script> | |
d3.select('#dni').on('input', function() { | |
let dni = +this.value; | |
let clase = dni * 0.000001474 + 1938.11; | |
let today = new Date(); | |
let edad = (1900 + today.getYear()) - clase; | |
d3.select('div#edad').text(edad.toFixed(1) + ' años'); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment