Start with node: My first I/O challenge

var fs = require('fs'); var text = fs.readFileSync("C:\...path\example.txt") var regx = /\n/g; text = text.toString().split(regx); console.log((text.length);
my example file is below (without a carriage return afert Line 4):

Line one. Line 1
Line two. Line 2
Line three. Line 3
Line four. Line 4

The ouput of the code (console.log) is 4 when i run my code but when i run learnyounode verify it say failed expected 33!

Need your insight!! Thank you !

** SOLVED**
just need to replace the hard file path with a variable path into which learnyoucode can put any test file.

I’m not very familiar with javascript, but learnyounode did not help by having me use the toString() function. Instead I just used String().

// filesystem operations
var fs = require(‘fs’);

// get the file path which will be passed in the 3rd argument
var filePath = process.argv[2];

var contents = fs.readFileSync(filePath);

contents = String(contents);
var myArray = contents.split(‘\n’);

console.log(myArray.length - 1);