forked from sgrouples/javascript-assignment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex05.js
122 lines (113 loc) · 3.48 KB
/
ex05.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
Use Array#filter to write a function called getShortMessages.
getShortMessages takes an array of objects with 'message' properties and returns an array of messages that are less than < 50 characters long.
The function should return an array containing the messages themselves, without their containing object.
Arguments
messages: an Array of 10 to 100 random objects that look something like this:
{
message: 'Esse id amet quis eu esse aute officia ipsum.' // random
}
Hint - try chaining some Array methods!
*/
var messages = [
{
message: "Dolore Lorem incididsunt duis."
},
{
message: "Eu voluptate incididunt veniam exercitation fugiat excepteur commodo ea eu exercitation est dolore laborum occaecat."
},
{
message: "Enim occaecat minim eu commodo ex qui exercitation nostrud eiusmod."
},
{
message: "Nostrud mollit et adin."
},
{
message: "Excepteur non et dolor Lorem dolor id id officia dolore consectetur ut."
},
{
message: "Tempor enim esse sunfugiat."
},
{
message: "Aliquip proident laboris dolor aliquip pariatur non."
},
{
message: "Culpa elit culpa ullamco voluptate labore esse excepteur nulla reprehenderit culpa cupidatat."
},
{
message: "Excepteur ut eu deserunt voluptate voluptate fugiat elit."
},
{
message: "Ad reprehenderit ex esse duis incididunt proident dolor qui proident."
},
{
message: "Laboris ut laborum nulla eu enim dolor mollit deserunt consectetur ipsum adipisicing occaecat minim."
},
{
message: "Ut incididunt pariatur sunt laborum pariatur velit sit pariatur consectetur ad anim enim."
},
{
message: "Cupidatat dolor laborum prdo."
},
{
message: "Commodo cupidatat proident officia labore et aute."
},
{
message: "Cillum qui velit nostrud deserunt mollit Lorem sint irure consectetur."
},
{
message: "Incididunt dolore non officia consequat amet eiusmod minim ad."
},
{
message: "Nisi nisi sit aliquip ad qui incididunt exercitation commodo dolor ut reprehenderit cupidatat labore exercitation."
},
{
message: "Nostrud mollit cupidatat do sunt magna consectetur anim ullamco mollit magna incididunt magna est."
},
{
message: "Fugiat proident incididunt et consectetur nulla laboris ullamco."
},
{
message: "Cillum commodo incididunt aliqua quis ut ad ex aliqua officia."
},
{
message: "Magna veniam eiusmod id labore veniam ullamco."
},
{
message: "Velit amet laboris voluptate Lorem sit velit duis ex laborum ex."
},
{
message: "Nulla esse qui enim qui sint fugiat qui id et cillum aliquip reprehenderit proident."
},
{
message: "Duis mollit sunt eu esse deserunt cupidatat laboris."
},
{
message: "Non ullamco consectetur proident dolore anim commodo et eu do exercitation qui exercitation sint sit."
},
{
message: "Est ullamco velit duis sunt aliqua ex sint aute."
},
{
message: "Lorem cupidatat in in magna do duis commodo nostrud in."
},
{
message: "Aliqua velit exercitation mollit aute."
},
{
message: "Tempor enim minim ut mollit irure cupidatat sit ea consectetur laboris proident ullamco sit."
},
{
message: "Excepteur culpa aute consectetur excepteur ipsum laboris ex aliquip culpa nostrud et aute Lorem."
}
];
function getShortMessages(messages){
return messages
.filter(function(obj){
return obj.message.length < 50;
})
.map(function(obj){
return obj.message;
});
}
console.log(getShortMessages(messages));