-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
24 lines (21 loc) · 1.25 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const names = ["Mehmet", "Elif", "Ali", "Muhammed", "Adal", "Ağıç", "Şaban", "Selahettin", "Demir", "Berk"];
const surnames = ["ABACIOĞLU", "ÇALIŞKANTÜRK", "DEMİR", "TURGUT", "ZÜMRÜT", "ELMAS", "BALLI", "ZORTLU", "KARTÇI", "DATACI"];
const generate = document.getElementById("generate-button");
const name = document.getElementById("name");
const surname = document.getElementById("surname");
const birthDate = document.getElementById("birth-date");
const age = document.getElementById("age");
generate.addEventListener("click", () => {
const randomName = names[Math.floor(Math.random() * names.length)];
const randomSurname = surnames[Math.floor(Math.random() * surnames.length)];
const randomYear = Math.floor(Math.random() * (2003 - 1940 + 1) + 1940);
const randomMonth = Math.floor(Math.random() * (12 - 1 + 1) + 1);
const randomDay = Math.floor(Math.random() * (31 - 1 + 1) + 1);
const today = new Date();
const currentYear = today.getFullYear();
const randomAge = currentYear - randomYear;
name.textContent = `İsim: ${randomName}`;
surname.textContent = `Soyisim: ${randomSurname}`;
birthDate.textContent = `Doğum Tarihi: ${randomMonth}/${randomDay}/${randomYear}`;
age.textContent = `Yaş: ${randomAge}`;
});