samedi 4 août 2018

testing js files using nodejs

I try to understand how to test js files. Look, I have a file emotify.js with function:

function emotify(string) {
 return string + '' + ' :)'; 
}

and then I created another file - index.js with the content below:

var emotify = require('./emotify.js');
console.log(emotify('just testing'));

but console push me an error

 TypeError: emotify is not a function

What is wrong ?

Aucun commentaire:

Enregistrer un commentaire