I’m trying to grab all the links from a webpage, sort those links, find links using a key word, and print links with key words in a list to the console. I am using the split() method to find links with the key word, however, while my hard-coded string will split correctly, the same code will not work when I try splitting a value from an array.
I have an array of URLS (arrCopy), and I want to use split() on the first array value. However, I can’t get it to work using the code below.
//arrCopy is an array of strings (URLs)
var tempStringArr = arrCopy[0]; //get first URL from arr
var tempStringSplit = tempStringArr.split("/"); //doesn't work!
If I hard-code a URL into a string, that same code works.
//this code works
var exampleString = "http://bit.do/contact.php?layout=js.do"; //hardcoded string
var exampleStringSplit = exampleString.split("/"); //array created from exampleString
My full code which demonstrates the above examples: http://js.do/gloss/90965
I’ve commented out the code that doesn’t work.
How can I get the split() method to work on array values? Am I just using split() incorrectly?
arrCopyare. It's obviously not an array of URLs as you say, the answers say that it's an array of DOM elements.