Very simple example here:
var u = []
u.push("https://cloudinary.com/products/media_optimizer/web-performance-guide#get-started")
u.includes("https://cloudinary.com/products/media_optimizer/web-performance-guide") //return false
What am I doing wrong here?
Iterate over the array, checking each element.
const search = (arr, fragment) => arr.some(v => v.includes(fragment));
const u = [
"https://cloudinary.com/products/media_optimizer/web-performance-guide#get-started"
];
const found = search(u, "https://cloudinary.com/products/media_optimizer/web-performance-guide");
console.log(found);
Reference:
The value you are searching for must be an exact match, and you are not searching for the ending #get-started
You are searching the array for an exact match to your string.
You can use .includes(...) on the string in the array which will return true.
u[0].includes("https://cloudinary.com/products/media_optimizer/web-performance-guide")