can you help me with this leardnyounode exercise (my first i / o)? [closed]

0

/ * Write a program that, using a synchronous call to the file system, reads a file received by argument and prints to console the number of line breaks ('\ n') it contains. Similar to run cat file | wc -l. The program will receive the path to the file as the only argument. * /

var fs = require('fs');

var NumeroDeLineas = fs.readFileSync(process.argv[2], 'utf-8')
var lineas = NumeroDeLineas/*.toString()*/.split('\n').lenght - 1;

console.log(lineas);
    
asked by Cristian Gallego 01.11.2018 в 17:54
source

1 answer

0

with my colleagues I was analyzing the code and we deduced that the error was in that it is not lenght and it is length

var fs = require('fs');

var NumeroDeLineas = fs.readFileSync(process.argv[2], 'utf-8')
var lineas = NumeroDeLineas.toString().split('\n').length - 1;

console.log(lineas);
    
answered by 03.11.2018 / 01:06
source