Skip to content

Commit

Permalink
馃 Error code returned if data file empty
Browse files Browse the repository at this point in the history
-1 is returned if a messages array is empty (fix #24)
  • Loading branch information
helmasaur committed Jan 1, 2020
1 parent f10c4c9 commit ad2a8d7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.js
Expand Up @@ -54,5 +54,9 @@ module.exports = language => {

// Returns a random string from an array
const randomMessage = array => {
return array[Math.floor(Math.random() * array.length)];
message = array[Math.floor(Math.random() * array.length)];
if (message === undefined || message === null) {
return -1;
}
return message;
}

0 comments on commit ad2a8d7

Please sign in to comment.