Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

240
Views
Uncaught (in promise) TypeError: lines.split is not a function //i am just trying to read the lines of my txt file and I cant
<script>
    let lines=[];
    let Array;
    fetch("questions.txt").then(response =>{
        console.log(response.status);
        response.text().then(response =>{
            console.log(response);
           Array=lines.split("\n");
        })
    });
</script>

i am just trying to read the lines of my txt file and I cant

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

lines is already an array. Arrays cannot be split, as they already contain multiple elements.

This is probably what you meant to do:

let lines;
fetch("questions.txt").then(response =>{
    console.log(response.status);
    response.text().then(response =>{
        console.log(response);
        lines=response.split(/\r?\n/);
    })
});

Source (for splitting into lines): https://github.com/30-seconds/30-seconds-of-code/blob/master/snippets/splitLines.md

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!