-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctionsMultiReturn.html
More file actions
38 lines (35 loc) · 1.13 KB
/
Copy pathfunctionsMultiReturn.html
File metadata and controls
38 lines (35 loc) · 1.13 KB
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
36
37
38
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Função com um retorno simples</title>
<style>
div{display: flex; flex-direction: column;}
h1{margin: 25px auto; width: 100%; background-color: darkgoldenrod; text-align: center; font-size: 24px; font-family: sans-serif; color: white;}
#button{margin: 0px auto; width: 200px;font-size: 24px;}
</style>
</head>
<body>
<div>
<h1>JS: FUNÇÕES</h1>
<input type="button" id="button" value="Mostrar nome">
</div>
<script>
//A função abaixo retorna um vetor 2 váriaveis dentro de um Array
//é possivel retornar quantas variáveis forem necessarias
function multiReturn(firstName, lastName, idade){
var nomeCompleto = firstName + " " + lastName;
var mostraIdade = "Idade: " + idade;
var pacoteNome = [nomeCompleto, mostraIdade];
return pacoteNome;
}
document.getElementById('button').onclick=function(){
var arrayNome = multiReturn("Renan", "Eduardo", 31);
console.log(arrayNome[0]);
console.log(arrayNome[1]);
console.log(arrayNome);
}
</script>
</body>
</html>