I have those lines of data:
1234;06/07/22;06/07/22;VRT; ;31070;some String content;some String content; ;147.10;A;1234
1234;06/07/22;06/07/22;VRT; ;31070;some String content;some String content; ;147.10;A;1234
1234;06/07/22;06/07/22;VRT; ;31070;some String content;some String content; ;147.10;A;1234
1234;06/07/22;06/07/22;VRT; ;31070;some String content;some String content; ;147.10;A;1234
1234;06/07/22;06/07/22;VRT; ;31070;some String content;some String content; ;147.10;A;1234
I want to count how much time the letter A
appeared in those lines it sould print 5
.
So what I have a file with 19 lines and all those lines has letter A
when I tried this snipped of code it returns to me just 12. here is the image for demonstration:
I tried this code:
let nLines = 0;
let counter = 0;
for (let i = 0, n = this.csvRecords.length; i < n; ++i) {
if (this.csvRecords[i] === '\n' && this.csvRecords.length[i][10] === 'A') {
++nLines;
counter++;
}
console.log("number of lines in the file is: ", this.csvRecords.length) // this is giving me 19 which is right
}
console.log(counter) // this is giving me 0 which is wrong
So console.log( "showing u[10] is: " , this.csvRecords[10].length);
is printing me the 10th line and it counts data with deliminer and that's not what i want I want how much it appeared in all the lines.