-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlove.js
21 lines (18 loc) · 821 Bytes
/
love.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function calculateLove() {
const name1 = document.getElementById('name1').value.trim();
const name2 = document.getElementById('name2').value.trim();
if (name1 === "" || name2 === "") {
alert("Please enter both names");
} else {
const lovePercentage = Math.floor(Math.random() * 101);
const result = document.getElementById('result');
result.innerHTML = `${name1} and ${name2}'s love percentage: ${lovePercentage}%`;
if (lovePercentage < 30) {
result.innerHTML += "<br>Not a great match, keep looking!";
} else if (lovePercentage >= 30 && lovePercentage < 70) {
result.innerHTML += "<br>There is potential. Give it a try!";
} else {
result.innerHTML += "<br>Great Match! Love is in the air!";
}
}
}