Answer to Question #250816 in HTML/JavaScript Web Application for Holik

Question #250816
3) Enter 2 words to write to the file from the keyboard. Delete the letters that occur in the second word from the first word. Display the result.
1
Expert's answer
2021-10-13T20:38:40-0400
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()
    })
})

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS