lundi 13 mai 2019

I am trying to replace a certain letter with another letter. JAVASCRIPT

I am trying to replace a certain letter in a .txt file with another letter. I.E replace all the "b" to a "p" and then replace all the "p" to a "b". I got to use if statements and for loops!

var fs = require('fs');
var files = fs.readFileSync("alice_in_wonderland.txt", "utf8");

for (var i = 0; i < files.length; i++) {       
        if ("b") {
                return "p"
        };

}

fs.writeFileSync("alice_in_wonderland_2.txt", files);

Aucun commentaire:

Enregistrer un commentaire