0

abc.txt

John 22-08-1998 Bangalore 1111111111

const k;
this.k = sessionStorage.getItem('loggedUser');
if (k.UpperCase() === 'MEGHANA') {
  const fs = require('fs')
  const text = fs.readFileSync('./MEGHANA.txt').toString('utf-8')
  const textByLine = text.split('\n')
  document.write(textByLine[0])
}

1
  • 1
    const textByLine = text.split('\n') gives you the whole line which you'd like to parse in to an array? Commented Jul 27, 2021 at 5:17

1 Answer 1

1

I hope this code is what you mean!

const k;
this.k = sessionStorage.getItem('loggedUser');
if (k.UpperCase() === 'MEGHANA') {
  const fs = require('fs');
  const text = fs.readFileSync('./MEGHANA.txt').toString('utf-8');
  const textByLine = text.split('\n');
  const textArray = textByLine[0].split(' ');
  textArray.forEach(t => document.write(t));
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.