-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtuitinho.js
54 lines (44 loc) · 1000 Bytes
/
tuitinho.js
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//Contruindo um CRUD em JAVASCRIPT simples
const tuitinho = {
usuarios: [
{
username: 'marcioreyes'
}
],
posts: [
{
id: 1,
date: '29/03/2024',
post: 'Primeiro tuitinho'
}
],
};
//Criar tuitinho
function criarTuit(dados){
tuitinho.posts.push(
{
id: dados.id + 1,
date: dados.date,
post: dados.post
}
);
};
//Ler tuitinho
function lerTuiti(id){
return tuitinho.posts[id-1];
};
//Atualizar tuitinhos
function atualizarConteudoTuiti(dados){
var lista_posts= lerTuiti(dados.id)
lista_posts.post= dados.post
tuitinho.posts[dados.id] = lista_posts
};
//Apagar tuitinhos
function apagarTuit(id){
};
criarTuit({id: tuitinho.posts.push(), date:'30/10/2024', usuarios:'marcioreyes', post:'Segundo tuitinho'})
criarTuit({id: tuitinho.posts.push(), date:'30/10/2024', usuarios:'marcioreyes', post:'Terceiro tuitinho'})
atualizarConteudoTuiti({id:2, post:'God Save The Queen'})
console.log(lerTuiti(1))
console.log(lerTuiti(2))
console.log(lerTuiti(3))