Currently, I am utilizing the browser console to scrape and organize content with JS. Below is the code snippet:
This represents my result array
var arr = [
"George\nPresident & Founder",
"content",
"Ronald\nCountry Director, America",
"content",
"Kriss, PhD\nVice President",
"content",
"Joseph, MS\nDirector",
"content",
"Elizabeth\nDevelopment Operations",
"content",
"Lisa, MFA, MBA\nU.S. Content",
"content.",
"Natalia\nCountry Director"
]
I have attempted the following:
for(var i=0; len = result.length, i < len; i++){
result[i]['something'] = [];
if(i === 0){
result[i].split('\n');
}
else if (i % 2 === 0) {
result[i].split('\n');
}
console.log(result[i]);
result[i]['test'].push(result[i]);
}
The issue I am encountering is that result[i]['something'] = []; is undefined. However, when I console.log(result[i]), I receive the correct output. I have tried copying using JSON.stringify(result[i]), but only get one object back.
for(var i=0; len = result.length, i < len; i++){
var arr = [];
if(i === 0){
result[i].split('\n');
}
else if (i % 2 === 0) {
result[i].split('\n')
}
arr.push(result[i])
// console.log(result[i]);
console.log(arr);
}
Unfortunately, this code does not split them; it merely pushes them into arrays.
When I console.log(result[i]), the output is as follows: (correct format, but not in strings or arrays, making it uncopyable)
George
President & Founder
content
Ronald
Country Director America
content
Kriss PhD
Vice President
content
Joseph MS
Director
content
Elizabeth
Development Operations
content
Lisa MFA MBA
U.S. Content
content
Natalia
Country Director
Ultimately, I aim for the final result to resemble this:
var result = [
["George"],
["President & Founder"],
[ "content" ],
[ "Ronald"]
["Country Director, America" ],
[ "content" ],
[ "Kriss, PhD"],
["Vice President" ],
[ "content" ],
[ "Joseph, MS"],
["Director" ],
[ "content" ],
[ "Elizabeth"],
["Development Operations" ],
[ "content" ],
[ "Lisa, MFA, MBA"],
["U.S. Content" ],
[ "content." ],
[ "Natalia"],
["Country Director" ],
[ "content." ]
]
Any suggestions on how to achieve the desired result[i] for copying onto clipboard using copy(JSON.stringify(result))?