A Code Poem

The Code

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
const poem = (
word1_1,
word1_2,
word2_1,
word2_2,
line3param,
line4param
) => {
const line1 = `${word1_1 || 'Roses'} are ${word1_2 || 'red'}.\n`;
const line2 = `${word2_1 || 'Violets'} are ${word2_2 || 'blue'}.\n`;
const line3 = `${line3param || 'Sugar is sweet'}.\n`;
const line4 = `${line4param || 'And so are you'}.`;
return line1 + line2 + line3 + line4;
}
const myPoem = poem(
'Dandelions',
'yellow',
'Boogers',
'green',
'I\'m a nice fellow',
'Whose nose is squeaky clean'
);
console.log(poem());
console.log(myPoem);

The Poem

1
2
3
4
5
6
7
8
9
10
"Roses are red.
Violets are blue.
Sugar is sweet.
And so are you."
"Dandelions are yellow.
Boogers are green.
I'm a nice fellow.
Whose nose is squeaky clean."

Make Your Own

JS Bin on jsbin.com

Here is a link.