diff --git a/challenges/challenge-cowsay-two/solution1.js b/challenges/challenge-cowsay-two/solution1.js index a7f2416b3..fde835b38 100644 --- a/challenges/challenge-cowsay-two/solution1.js +++ b/challenges/challenge-cowsay-two/solution1.js @@ -7,6 +7,11 @@ // 1. Accept arguments // how will you accept arguments? +if (process.argv.length<3) { + console.error(`Usage: ${process.argv[0].split("/").slice(-1)} ${process.argv[1].split("/").slice(-1)} STRING`); + console.error(` e.g.: ${process.argv[0].split("/").slice(-1)} ${process.argv[1].split("/").slice(-1)} 'Mooooo'`); + process.exit(1); +} // 2. Make supplies for our speech bubble @@ -18,13 +23,23 @@ let saying = ''; function cowsay(saying) { // how will you make the speech bubble contain the text? + saying = (saying=="" ? "Mooooo" : saying); + console.log(` ${topLine.repeat(saying.length+2)} `); + console.log(`< ${saying} >`); + console.log(` ${bottomLine.repeat(saying.length+2)} `); // where will the cow picture go? + console.log(" \\ ^__^ "); + console.log(" \\ (oo)\\_______ "); + console.log(" (__)\\ )\\/\\"); + console.log(" ||----w | "); + console.log(" || || "); // how will you account for the parameter being empty? - + console.log(''); } //4. Pipe argument into cowsay function and return a cow // how will you log this to the console? +cowsay(process.argv.slice(2).join(" ")); \ No newline at end of file diff --git a/challenges/challenge-cowsay-two/solution2.js b/challenges/challenge-cowsay-two/solution2.js index 8aca8572c..40c4904ea 100644 --- a/challenges/challenge-cowsay-two/solution2.js +++ b/challenges/challenge-cowsay-two/solution2.js @@ -5,14 +5,37 @@ // ================= // 1. Make a command line interface. +import readline from 'node:readline'; + +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, +}); // 2. Make supplies for our speech bubble +let topLine = '_'; +let bottomLine = '-'; +let saying = ''; // 3. Make a cow that takes a string const cow = (saying) => { // how did you make the cow before? + saying = (saying=="" ? "Mooooo" : saying); + console.log(` ${topLine.repeat(saying.length+2)} `); + console.log(`< ${saying} >`); + console.log(` ${bottomLine.repeat(saying.length+2)} `); + console.log(" \\ ^__^ "); + console.log(" \\ (oo)\\_______ "); + console.log(" (__)\\ )\\/\\"); + console.log(" ||----w | "); + console.log(" || || "); + console.log(''); } // 4. Use readline to get a string from the terminal -// (with a prompt so it's clearer what we want) \ No newline at end of file +// (with a prompt so it's clearer what we want) +rl.question("What does the cow say? ", answer => { + cow(answer); + rl.close(); +}); \ No newline at end of file diff --git a/challenges/challenge-weather-app/assets/globals.css b/challenges/challenge-weather-app/assets/globals.css index c9742ea5c..7e6457a27 100644 --- a/challenges/challenge-weather-app/assets/globals.css +++ b/challenges/challenge-weather-app/assets/globals.css @@ -37,7 +37,8 @@ body { font-size: 14px; background: center center no-repeat; background-size: contain; - color: #333; + background-color: #333; + color: #ccc; } a { diff --git a/challenges/challenge-weather-app/index.html b/challenges/challenge-weather-app/index.html index b1add346a..fcf223601 100644 --- a/challenges/challenge-weather-app/index.html +++ b/challenges/challenge-weather-app/index.html @@ -44,6 +44,61 @@