html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Love Calculator</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>❤️ Love Calculator ❤️</h1>
<p>Enter two names and find out your love compatibility!</p>
<input type="text" id="name1" placeholder="Your Name">
<input type="text" id="name2" placeholder="Partner's Name">
<button onclick="calculateLove()">Calculate</button>
<div id="result"></div>
</div>
<script src="script.js"></script>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
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
body {
font-family: Arial, sans-serif;
background: linear-gradient(45deg, #ff758c, #ff7eb3);
text-align: center;
padding: 20px;
color: white;
}
.container {
background: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
width: 250px;
margin: auto;
color: #333;
}
h1 {
color: #ff4d6d;
}
input {
width: 90%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 5px;
Enter to Rename, Shift+Enter to Preview
js
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
function calculateLove() {
// Get the names from the input fields
var name1 = document.getElementById("name1").value.trim();
var name2 = document.getElementById("name2").value.trim();
// Ensure that we have both names before proceeding
if (name1 === "" || name2 === "") {
document.getElementById("result").innerHTML = "Please enter both names.";
return;
}
// Combine both names and convert them to lowercase
var combinedNames = name1.toLowerCase() + name2.toLowerCase();
// Calculate a love score based on the letters in the combined names
var score = 0;
for (var i = 0; i < combinedNames.length; i++) {
score += combinedNames.charCodeAt(i); // Sum up the ASCII values of the characters
}
// A consistent love percentage based on the score, modded by 101 to ensure it's between 0 and 100
var lovePercentage = score % 101;
// Display the result
document.getElementById("result").innerHTML = `Love Compatibility: ${lovePercentage}%`;
}
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run