Skip to content

Commit 1578ae0

Browse files
authored
Add files via upload
1 parent 6fda0c8 commit 1578ae0

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Document</title>
7+
</head>
8+
<body>
9+
<h1>Problem Solving 5</h1>
10+
<script src="commonCharacters.js"></script>
11+
</body>
12+
</html>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const commonCharacters = (str1, str2) => {
2+
let result = [];
3+
for (let i = 0; i < str1.length; i++) {
4+
let found = false;
5+
for (let j = 0; j < str2.length; j++) {
6+
if(str1[i]==str2[j])
7+
{
8+
found = true;
9+
break;
10+
}
11+
}
12+
if(found && !result.includes(str1[i]))
13+
result.push(str1[i]);
14+
}
15+
return result.join('');
16+
};
17+
console.log(commonCharacters('acexivou', 'aegihobu')); // it must return aeiou

0 commit comments

Comments
 (0)