-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
66 lines (49 loc) · 2.02 KB
/
index.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//create function to validate user input
//variables
function validate() {
var date = document.getElementById("date").value;
console.log(date);
var month = document.getElementById("month").value;
console.log(month);
var year = document.getElementById("year").value;
console.log(year);
//dayofthe week calculation
if (date == " " || month == " " || year == " ") {
return false;
} else {
var CC = year.slice(2);
var YY = year.slice(-2);
console.log("CC" + CC + "YY" + YY)
let fullBirthday = year + "-" + month + "-" + date;
let dayvalue = new Date(fullBirthday);
console.log(dayvalue);
let dayOfTheWeek = dayvalue.getDay();
return dayOfTheWeek;
}
}
//akan names function
function myAkanName() {
let femaleNames = ["Akosua", "Adwoa", "Abenaa", "Akua", "Yaa", "Afua", "Ama"];
let maleNames = ["Kwasi", "Kwadwo", "Kwabena", "Kwaku", "Yaw", "Kofi", "Kwame"];
let weekDays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var genders = document.getElementsByName("gender");
//console.log(gender);
genders.forEach((gender) => {
if (gender.checked) {
console.log(`You checked: ${gender.value}`);
console.log(gender.value);
console.log(gender);
//conditions
if (gender.value === "Female") {
document.querySelector(".any").innerHTML = "Your Akan name is" + femaleNames[validate()];
document.querySelector(".text").innerHTML = "Your birth day is" + weekDays[validate()];
console.log("Your Akan name is" + femaleNames[validate()]);
}
else if (gender.value === "Male") {
document.querySelector(".any").innerHTML = "Your Akan name is" + maleNames[validate()];
document.querySelector(".text").innerHTML = "Your birth day is" + weekDays[validate()];
console.log("Your Akan name is" + maleNames[validate()]);
}
}
})
}