From 0bd17160c1186652ffaf2fa2353ee6ccc58b72c5 Mon Sep 17 00:00:00 2001 From: adada Date: Mon, 14 Sep 2020 00:12:46 -0400 Subject: [PATCH] Adewale-Mateen --- Adewale-Mateen-solution.txt | 120 ++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 Adewale-Mateen-solution.txt diff --git a/Adewale-Mateen-solution.txt b/Adewale-Mateen-solution.txt new file mode 100644 index 0000000..85c4874 --- /dev/null +++ b/Adewale-Mateen-solution.txt @@ -0,0 +1,120 @@ +// Get Even +// Write a for loop that will log only the even numbers in 0 through 200. +for (let i = 0; i <= 200; i++) { + if (i%2 === 0){ + console.log(i); + } + } + + // Excited Kitten + // Write code that logs "Love me, pet me! HSSSSSS!" 10 times. + for (let i = 0; i < 10; i++){ + console.log("Love me, pet me! HSSSSSS!"); + } + + // For every even number in your loop, log "...human...why you taking pictures of me?...", "...the catnip made me do it...", "meow?", or "...why does the red dot always get away..." at random. + + const meow1 = "...human...why you taking pictures of me?..." + const meow2 = "...the catnip made me do it..." + const meow3 = "meow?" + const meow4 = "...why does the red dot always get away..." + + for (let i = 0; i < 10; i++){ + // console.log("Love me, pet me! HSSSSSS!"); + const randomMeow = Math.floor(Math.random()*5); + if (i%2 === 0){ + if (randomMeow === 1){ + console.log(meow1); + }else if (randomMeow === 2){ + console.log(meow2); + }else if (randomMeow === 3){ + console.log(meow3); + }else{ + console.log(meow4); + } + } + } + + + // Thermostat + // Declare a variable called currentTemp that stores the current temperature. Set this to a random whole number between 1 and 100. + + let currentTemp = Math.floor(Math.random()*100) + + // Declare a variable called desiredTemp that is the temperature in Fahrenheit, that you personally like to relax at. (For most of us, this is between 68 and 72!) + + const desiredTemp = 70; + + // Print out the current temperature is. + + console.log("The current temperature is", currentTemp +"F"); + + // While the temperature is too high, subtract a degree from the current temperature. Every time you decrease the temperature, print out the current temperature again. + + // let i = currentTemp; + // while (i > desiredTemp) { + // i--; + // console.log(i); + // } + + + // Fizz Buzz + + // Write a javascript application that logs all numbers from 1 - 100. + // If a number is divisible by 3 log "Fizz" instead of the number. + for (let i = 1; i < 101; i++){ + if(i%3===0){ // If a number is divisible by 3 log "Fizz" instead of the number. + console.log("Fizz"); + }else if (i%5===0){ //If a number is divisible by 5 log "Buzz" instead of the number. + console.log("Buzz"); + }else if (i%3 === 0 && i%5 === 0){ //If a number is divisible by 3 and 5 log "FizzBuzz" instead of the number. + console.log("FizzBuzz"); + } else { + console.log(i); + } + } + + + // BONUS: WHAT'S MU NUMBER? + // Use a for...in loop to examine the phoneBook Object below and print out the names of all the people who share the phone number "333-333-3333". + + + var phoneBook = { + "Abe": "111-111-1111", + "Bob": "222-222-2222", + "Cam": "333-333-3333", + "Dan": "444-444-4444", + "Ern": "555-555-5555", + "Fry": "111-111-1111", + "Gil": "222-222-2222", + "Hal": "333-333-3333", + "Ike": "444-444-4444", + "Jim": "555-555-5555", + "Kip": "111-111-1111", + "Liv": "222-222-2222", + "Mia": "333-333-3333", + "Nik": "444-444-4444", + "Oli": "555-555-5555", + "Pam": "111-111-1111", + "Qiq": "222-222-2222", + "Rob": "333-333-3333", + "Stu": "444-444-4444", + "Tad": "555-555-5555", + "Uwe": "111-111-1111", + "Val": "222-222-2222", + "Wil": "333-333-3333", + "Xiu": "444-444-4444", + "Yam": "555-555-5555", + "Zed": "111-111-1111" + } + + for (var name in phoneBook) { + if (phoneBook[name] === "333-333-3333") { + console.log(name); + } + } + + + + + \ No newline at end of file