-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0bb9d15
commit e6a9643
Showing
5 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
function bffTest(input) { | ||
const [name1, name2] = input.split(','); | ||
const cleanName1 = name1.replace(/\s+/g, '').toLowerCase(); | ||
const cleanName2 = name2.replace(/\s+/g, '').toLowerCase(); | ||
|
||
let commonLetters = 0; | ||
const letters = {}; | ||
|
||
for (let i = 0; i < cleanName1.length; i++) { | ||
letters[cleanName1[i]] = true; | ||
} | ||
|
||
for (let i = 0; i < cleanName2.length; i++) { | ||
if (letters[cleanName2[i]]) { | ||
commonLetters++; | ||
} | ||
} | ||
|
||
const capitalizeFirstLetter = (string) => string.charAt(0).toUpperCase() + string.slice(1); | ||
|
||
const formattedName1 = capitalizeFirstLetter(name1.trim()); | ||
const formattedName2 = capitalizeFirstLetter(name2.trim()); | ||
|
||
if (commonLetters > 3) { | ||
echo (`${formattedName1} and ${formattedName2} are BFFs!`); | ||
} else { | ||
echo (`${formattedName1} and ${formattedName2} are not BFFs.`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
function compatibilityTest(input) { | ||
const [name1, name2] = input.split(','); | ||
|
||
const cleanName1 = name1.replace(/\s+/g, '').toLowerCase(); | ||
const cleanName2 = name2.replace(/\s+/g, '').toLowerCase(); | ||
|
||
let score = 0; | ||
for (let i = 0; i < cleanName1.length; i++) { | ||
score += cleanName1.charCodeAt(i); | ||
} | ||
for (let i = 0; i < cleanName2.length; i++) { | ||
score += cleanName2.charCodeAt(i); | ||
} | ||
|
||
score = score % 100; // Ensure score is between 0 and 100 | ||
|
||
let compatibility; | ||
if (score > 75) { | ||
compatibility = 'High'; | ||
} else if (score > 50) { | ||
compatibility = 'Medium'; | ||
} else { | ||
compatibility = 'Low'; | ||
} | ||
|
||
const capitalizeFirstLetter = (string) => string.charAt(0).toUpperCase() + string.slice(1); | ||
|
||
const formattedName1 = capitalizeFirstLetter(name1.trim()); | ||
const formattedName2 = capitalizeFirstLetter(name2.trim()); | ||
|
||
echo(`${formattedName1} and ${formattedName2} have ${compatibility} compatibility with a score of ${score}`); | ||
} |