Tell me how to get data from a .txt file and compare it with what the user entered. str - what the user entered

$scope.praviloThree = function (str) { var count= 0; ///считать файл var text = "" for(var i =0; i<text.length; i++) { if(str == text)count++; } return count; 

I will have to compare 123456 with str, and so on with the entire file

the data in the file looks like this

    1 answer 1

    You can get this file only by downloading it through the form, well, then split it into lines, in this case.

     $('#file_button').on('change', function (event) { var reader = new FileReader(); reader.onload = function (e) { var rows = e.target.result.split(/\r\n/); for (var i = 0; i < rows.length; i++) { // умная логика сравнения } }; reader.readAsText(event.target.files[0]); });