function getCommonCharacters(str1, str2) {
let strcommon = "";
for (let i in str1) {
if (str2.includes(str1[i])) {
if (! strcommon.includes(str1[i])) {
strcommon += str1[i];
}
}
}
return strcommon;
}
const str1 = "c c++ c# java go";
const str2 = "python nodejs php javascript";
let strcommon = getCommonCharacters(str1, str2);
console.log("Same letters are: " + strcommon);
/*
run:
Same letters are: c javo
*/