How add space after each characters in jQuery

As we know that the split() method is used to split a string into an array. If you pass empty string in split method then it split each chrachter into an array. After that we do a for loop in array and add a space in each item and store the vlaue in a new variable.
CODE
<!DOCTYPE html>
<html>
<head>
  <title>jQuery With Example</title>
  <script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
  <script type="text/javascript">
    $(function () {
      $('.btnClick').click(function () {
        var cName = "INDIA";
        var cArray = cName.split("");
        var cNewName = "";

        for (var i = 0; i < cArray.length; i++) {
          cNewName += cArray[i] + " ";
        }
        alert(cNewName);

      });

    });
  </script>
</head>
<body>
  <div>
    <input type="button" class="btnClick Button" value="Click" />
  </div>
</body>
</html>
DISPLAY

No comments :

Please Give Your Feedback