Hi, I need help for JS code. I could not read dancers.txt with belowing code. Please don’t say to me about use read(). I tried to in below code block. Also, I have a another problem. In sublime text, .split("\n") is wrong for editor. I did not initialize it. What can I do? Thanks for yours helping comment.
// For reading .txt file code block
var fs = require("fs");
var text = fs.readFileSync("./dancers.txt");
var textByLine = text.split("\n")
// General Code
function getDancers(males, females) {
var names = read("dancers.txt").split("\n");
for (var i = 0; i < names.length; ++i) {
names[i] = names[i].trim();
}
for (var i = 0; i < names.length; ++i) {
var dancer = names[i].split(" ");
var sex = dancer[0];
var name = dancer[1];
if (sex == "F") {
females.enqueue(new Dancer(name, sex));
} else {
males.enqueue(new Dancer(name, sex)); }
} }