Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@seoutopico
Created June 15, 2022 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seoutopico/d98be0505bfb8fa591fd5c3f71124f72 to your computer and use it in GitHub Desktop.
Save seoutopico/d98be0505bfb8fa591fd5c3f71124f72 to your computer and use it in GitHub Desktop.
//Obtener la categoria según la URL
function getCategory(url) {
//var url = "https://www.mismascotas.es/219-golosinas-snacks-gatos";
let mapa= new Map();
mapa.set("Cat Perros","perros");
mapa.set("Cat Gatos","gatos");
for (let values of mapa.values()) {
var verificar = url.split("-").includes(values);
if(verificar === true){
return(values)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment