From 6d52c3372a2d11c7717c6c03c7502bdf5c2ed16a Mon Sep 17 00:00:00 2001 From: Hadis Jamali Date: Wed, 8 Nov 2023 10:34:38 +0100 Subject: [PATCH] update RP --- 3_javascript/javascript1/week1/index.html | 12 ++++ 3_javascript/javascript1/week1/script.js | 86 +++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 3_javascript/javascript1/week1/index.html create mode 100644 3_javascript/javascript1/week1/script.js diff --git a/3_javascript/javascript1/week1/index.html b/3_javascript/javascript1/week1/index.html new file mode 100644 index 00000000..80af020a --- /dev/null +++ b/3_javascript/javascript1/week1/index.html @@ -0,0 +1,12 @@ + + + + + + hadis-js-week1 + + +

Hadis Jamali

+ + + diff --git a/3_javascript/javascript1/week1/script.js b/3_javascript/javascript1/week1/script.js new file mode 100644 index 00000000..3ae82f4f --- /dev/null +++ b/3_javascript/javascript1/week1/script.js @@ -0,0 +1,86 @@ +//Age-ify (A future age calculator) + +const yearOfBirth = 1995; +const yearFuture = 2045; +console.log(typeof yearFuture); +const curentYear = 2023; +const age = curentYear - yearOfBirth; +console.log(age); +const futureAge = yearFuture - curentYear + age; +console.log(futureAge); +console.log(`You will be ${futureAge} years old in ${yearFuture}`); + +//Goodboy-Oldboy (A dog age calculator) + +const dogYearOfBirth = 2018; +const dogYearFuture = 2045; +const dogYear = 2023; +const result = dogYear - dogYearOfBirth; +console.log(result); +const dogFutureAge = dogYearFuture - dogYear + result; +console.log(dogFutureAge); +const shouldShowResultInDogYears = true; +if (shouldShowResultInDogYears === true) { + console.log(`Your dog will be ${dogFutureAge} dog years old in ${dogYearFuture}`); +} else { + console.log(`Your dog will be ${dogFutureAge} human years old in ${dogYearFuture}`); +} + +//Housey pricey (A house price estimator) + +const volumeInMeters1 = 8 * 10 * 10; +const housePrice1 = 2500000; +const gardenSizeInM2Peter = 100; +const calculatedHousePrice = volumeInMeters1 * 2.5 * 1000 + gardenSizeInM2Peter * 300; +if (housePrice1 > calculatedHousePrice) { + console.log("too expensive"); +} else if (housePrice1 === calculatedHousePrice) { + console.log("price is good"); +} else { + console.log("cheap"); +} + +const volumeInMeters2 = 5 * 11 * 8; +const housePrice2 = 1000000; +const gardenSizeInM2Julia = 70; +const calculatedHousePrice2 = volumeInMeters2 * 2.5 * 1000 + gardenSizeInM2Julia * 300; +if (housePrice2 > calculatedHousePrice2) { + console.log("too expensive"); +} else if (housePrice2 === calculatedHousePrice2) { + console.log("price is good"); +} else { + console.log("cheap"); +} + +//Ez Namey (Startup name generator) Optional + +const firstWords = [ + "Easy", + "Awesome", + "Corporate", + "Nice", + "Great", + "Big", + "Team", + "Prety", + "Beautiful", + "Brilliant", +]; +const secondWords = [ + "Hope", + "Vestas", + "Dansk", + "Fotex", + "Rema", + "Jysk", + "Ikea", + "Lidl", + "Aldi", + "Asus", +]; + +const randomNumber = Math.floor(Math.random() * 10); +console.log(randomNumber); +const startupName = firstWords[randomNumber] + " " + secondWords[randomNumber]; +console.log(startupName); +console.log(startupName.length);