Seems okay to me to be honest. What you could do is replace the "50" with a variable in your js file.
var MESSAGE_MAX_LENGTH= 50;
And re position a bit the way you address the function
function getShortMessages(messages) {
return messages
.filter( (messageObject) => {
return messageObject.message.length < MESSAGE_MAX_LENGTH
})
.map( (messageObject) => {
return messageObject.message
});
}
Also I find that when addressing an array of messages
and running through the filter
function, it is better to not call the object messages
but item
or messageObject
moreover, object
in the map
function is a bit ominous, call it messageObject
again for example so you know what you are using specifically