-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtweetBank.js
44 lines (33 loc) · 1.3 KB
/
tweetBank.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
const _ = require("lodash");
var data = [];
var id = 1000;
function add(name, content) {
data.push({ name: name, content: content, id: generateID().toString() });
}
function generateID() {
id++;
return id;
}
function list() {
return _.cloneDeep(data);
}
function find(properties) {
return _.cloneDeep(_.filter(data, properties));
}
module.exports = { add: add, list: list, find: find };
const randArrayEl = function(arr) {
return arr[Math.floor(Math.random() * arr.length)];
};
const getFakeName = function() {
const fakeFirsts = ['Nimit', 'David', 'Shanna', 'Emily', 'Scott', 'Karen', 'Ben', 'Dan', 'Ashi', 'Kate', 'Omri', 'Gabriel', 'Joe', 'Geoff'];
const fakeLasts = ['Hashington', 'Stackson', 'McQueue', 'OLogn', 'Ternary', 'Claujure', 'Dunderproto', 'Binder', 'Docsreader', 'Ecma'];
return randArrayEl(fakeFirsts) + " " + randArrayEl(fakeLasts);
};
const getFakeTweet = function() {
const awesome_adj = ['awesome', 'breathtaking', 'amazing', 'funny', 'sweet', 'cool', 'wonderful', 'mindblowing', 'impressive'];
return "Fullstack Academy is " + randArrayEl(awesome_adj) + "! The instructors are just so " + randArrayEl(awesome_adj) + ". #fullstacklove #codedreams";
};
for (let i = 0; i < 10; i++) {
module.exports.add(getFakeName(), getFakeTweet());
}
console.log(data);