Skip to content

Instantly share code, notes, and snippets.

@aaizemberg
Last active March 20, 2024 19:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaizemberg/d133b84901873b837ea7a6de96a4cfc2 to your computer and use it in GitHub Desktop.
Save aaizemberg/d133b84901873b837ea7a6de96a4cfc2 to your computer and use it in GitHub Desktop.
Dame tu DNI y te estimo la edad
<!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