Mám dvě proměnné:
site1 = "www.somesite.com"; site2 = "www.somesite.com/";
Chci udělat něco takového
function someFunction(site) { // If the var has a trailing slash (like site2), // remove it and return the site without the trailing slash return no_trailing_slash_url; }
Jak to udělám?
Odpověď
Zkuste toto:
function someFunction(site) { return site.replace(//$/, ""); }