Receba uma string contendo números separados por vírgulas. Utilize split() para separar os números e exibi-los no console.
HTML (PEDIR PARA O CHATGPT CRIA APENAS O HTML) :
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Desafio Split - Números</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 50px;
}
.container {
max-width: 600px;
margin: 0 auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 10px;
background-color: #f9f9f9;
}
input[type="text"] {
width: 100%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
}
button {
width: 100%;
padding: 10px;
background-color: #007bff;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
}
button:hover {
background-color: #0056b3;
}
.resultado {
margin-top: 20px;
font-size: 1.2em;
}
</style>
</head>
<body>
<div class="container">
<h2>Desafio Split - Números</h2>
<p>Digite números separados por vírgulas:</p>
<input type="text" id="inputNumeros" placeholder="Exemplo: 1,2,3,4,5">
<button onclick="processarNumeros()">Processar Números</button>
<div class="resultado" id="resultado"></div>
</div>
<script src="app.js"></script>
</body>
</html>
JAVASCRIPT:
function processarNumeros () {
let number = document.getElementById('inputNumeros').value;
let text = document.getElementById('resultado');
let result = number.split(',');
text.innerHTML = result;
}