Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

javascript1-week1/hadis #60

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions 3_javascript/javascript1/week1/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>hadis-js-week1</title>
</head>
<body>
<h1>Hadis Jamali</h1>
</body>
<script src="./script.js"></script>
</html>
86 changes: 86 additions & 0 deletions 3_javascript/javascript1/week1/script.js
Original file line number Diff line number Diff line change
@@ -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);
Loading