const rl = require('readline')
const path = require('path')
const fs = require('fs')
const readline = rl.createInterface({
input: process.stdin,
output: process.stdout
})
readline.question('Enter the first word: ', (firstWord) => {
readline.question('Enter the second word: ', (secondWord) => {
fs.writeFileSync(path.join(__dirname, 'file.txt'), firstWord + ' ' + secondWord)
let first = firstWord.split('')
let second = secondWord.split('')
let string = ''
for (let i of first) {
let counter = 0
for (let j of second) {
if (i !== j) counter++;
}
if (counter === first.length) string += i
}
console.log(string);
process.exit()
})
})
Comments
Leave a comment