forked from mr-body/bookstoreHTML
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.html
More file actions
35 lines (28 loc) · 937 Bytes
/
code.html
File metadata and controls
35 lines (28 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Últimos Dígitos</title>
<style>
.texto {
font-size: 18px;
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="texto" id="textoOriginal">1234567890</div>
<div class="texto" id="ultimosDigitos"></div>
<script>
// Obtém o texto original da div
var textoOriginal = document.getElementById('textoOriginal').innerText;
// Obtém os últimos 4 dígitos
var ultimosDigitos = textoOriginal.slice(-4);
// Substitui os caracteres anteriores aos últimos dígitos por asteriscos
var textoCensurado = "*".repeat(textoOriginal.length - ultimosDigitos.length) + ultimosDigitos;
// Exibe os últimos dígitos na div
document.getElementById('ultimosDigitos').innerText = "Últimos dígitos: " + textoCensurado;
</script>
</body>
</html>