-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformat-output.js
18 lines (17 loc) · 1.11 KB
/
format-output.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module.exports = formatOutput
function formatOutput (response) {
var output = 'Here are your Articles: '
for (var i = 0; i < (5 || response.articles.length); i++) {
var articleCount = i + 1
if (response.articles[i].title !== null && response.articles[i].description !== null) {
output = output + articleCount + '. ' + response.articles[i].title + ' <break time="500ms" /> ' + response.articles[i].description + ' <break time="500ms" />'
} else if (response.articles[i].title !== null && response.articles[i].description === null) {
output = output + articleCount + '. ' + response.articles[i].title + ' <break time="500ms" /> ' + ' no description ' + ' <break time="500ms" />'
} else if (response.articles[i].title === null && response.articles[i].description !== null) {
output = output + articleCount + '. ' + ' no title ' + ' <break time="500ms" /> ' + response.articles[i].description + ' <break time="500ms" />'
} else {
output = output + articleCount + '. ' + ' no title ' + ' <break time="500ms" /> ' + ' no description ' + ' <break time="500ms" />'
}
}
return output
}