// utils.js
function removeNonCommonLetters(word1, word2) {
let result = '';
for (let char of word1) {
if (word2.includes(char)) {
result += char;
}
}
return result;
}
// You can export the function if you want to use it as a module
module.exports = removeNonCommonLetters;
// index.js
const word1 = "forest";
const word2 = "tor";
const result = removeNonCommonLetters(word1, word2);
console.log(result);
/*
run:
ort
*/