generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathsolution1.js
41 lines (32 loc) · 928 Bytes
/
solution1.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
// =================
// Stripped down cowsayer CLI,
// no libraries
// https://nodejs.dev/learn/nodejs-accept-arguments-from-the-command-line
// =================
// 1. Accept arguments
// how will you accept arguments?
const argument = (process.argv[2]) ? process.argv.slice(2) : ""
// 2. Make supplies for our speech bubble
let topLine = '_';
let bottomLine = '-';
let saying = `< ${argument.join(" ")}> `;
// 3. Make a cow that takes a string
function cowsay(saying) {
// how will you make the speech bubble contain the text?
console.log(`
${topLine.repeat(saying.length)}
${saying}
${bottomLine.repeat(saying.length)}
/
/
^__^ /
(oo)'_______
(__) )-~
||----w |
|| ||`)
// where will the cow picture go?
// how will you account for the parameter being empty?
}
//4. Pipe argument into cowsay function and return a cow
// how will you log this to the console?
cowsay(saying)