Hi all ,
I have an array read as a string[]
Now is a huge text with each new words separated with a comma
I want to read and save data, but when a certain word appears I want to stop and just save only save data uptill that point.
here is my code where are my going wrong?
for now everything still gets saved .
var mylist=Somerawdata;
var expectedWords="my name is Garner Eric";
for(let i =0;i<.length;i++){
if(mylist[i]===expectedWords)break
console.log(mylist[i]);
}
What I have tried:
var mylist=Somerawdata;
var expectedWords="my name is Garner Eric";
for(let i =0;i<.length;i++){
if(mylist[i]===expectedWords)break
console.log(mylist[i]);
}
For anyone looking at this after following suggestions from
W∴ Balboos, GHB
I implemented it like this ==>
This solution works as per guidance from
W∴ Balboos, GHB
<pre>var mylist=Somerawdata;
var expectedWords="my name is Garner Eric";
for(let i =0;i<.length;i++){
if(mylist===expectedWords)
mylist.substring(0, mylist.indexOf(expectedWords));
console.log(mylist);