Search code examples
javascriptgoogle-tag-manager

Uppercase a javascript function


Im getting some variable for the URL, but I'm getting as a lowercase and I would like to get it uppercase. This is the javascript that I'm running. How can I get it in Uppercase as return???

thanks

    function() {
  var pageUrl = window.location.href;
  return pageUrl.split("/")[3];
}

Solution

  • Use toUpperCase

    function foo() {
      var pageUrl = window.location.href;
      return pageUrl.split("/")[3].toUpperCase();
    }
    
    console.log(foo());