Header Ads Widget

BCA Information

nodeslip15a

 var fs = require('fs')

function countOccurences(string, word) {

    return string.split(word).length - 1;

}

var text = fs.readFileSync('demo.txt', 'utf8');

var count = countOccurences(text, "and"); 

if(count==0){

    console.log("not found")

}else{

console.log(count);

}

 


Post a Comment

0 Comments

Popular Posts

OOSE Notes
Data Mining And Data Science