From 45212ff686c49d5708b5e5a2c15ca86a9649079e Mon Sep 17 00:00:00 2001 From: evab1209 Date: Fri, 28 Aug 2020 00:23:09 -0400 Subject: [PATCH] Evas Loops --- solution.txt | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 solution.txt diff --git a/solution.txt b/solution.txt new file mode 100644 index 0000000..cd2d0da --- /dev/null +++ b/solution.txt @@ -0,0 +1,51 @@ +// "Get Even" +for (let i = 0; i <= 200; i+=2){ + console.log(i); +} + +// "Excited Kitten Part 1" +for ( let i = 0; i < 10; i++){ + console.log("Love me, pet me! HSSSSSS!"); +} + +// " Excitd Kitten Part 2" +for ( let i = 0; i < 10; i++){ + const sentences = ["...human...why you taking pictures of me?...", "...the catnip made me do it...", "meow?", "...why does the red dot always get away..."]; + if (i % 2 === 0) { + const randomNumber = Math.floor(Math.random()*sentences.length); + console.log(sentences[randomNumber]) + } +} + +// "Thermostat" + +let currentTemp = Math.floor(Math.random() * 101); +const desiredTemp = 72; + +console.log('The temperature is: ' + currentTemp + 'F'); + +while (currentTemp < desiredTemp) { + currentTemp++; + console.log("The temperature is now: " + currentTemp + 'F'); +} + +while (currentTemp > desiredTemp) { + currentTemp--; + console.log("The temperature is now: " + currentTemp + 'F'); +} + +// "FizzBuzz" + +for (let i= 1; i < 100; i++){ + if (i % 3 === 0){ + console.log("Fizz"); + } + else if (i % 5 === 0){ + console.log("Buzz"); + } + else if (i % 3 === 0 && i % 5 === 0){ + console.log("FizzBuzz"); + } else { + console.log(i) + } +} \ No newline at end of file