Question: i am used in Angular and Nativescript. I would like to try Typescript only template for nativescript (tns create myApp --template tsc)... but i need to have a shared Service as i would in Angular... can this be done in Vanilla typescript Nativescript ?

Thanks in advance

Answer: 
The following code will do the job!

```js
var tag_count = 0;
   var tag_array = [];
   $("#tag_name").click(function(){
      var tag = ""+$("#tag_name").val();
       if(!tag == ""){
        if(tag_array.indexOf(tag) < 0){
         tag_array.push(tag);
         tag_count = tag_count+1;
         console.log(tag_array);
            if(tag_count != 11){
               $(".tags").append("<div style=\"margin: 5px;\" class=\"tag\"><p>"+tag+"</p><a href=\"#\">x</a></div>");
            } else {
               $(".tags").append("<div style=\"margin: 5px;\" class=\"tag\"><p>15 tags already selected!</p><a href=\"#\">x</a></div>");
               $("#tag_name").attr("disabled","disabled");
            }
         }else{
              console.log("Alredy Tagged - "+tag);
            }
      }
   });
```

```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select multiple="multiple" size="10" id="tag_name">
   <option>apple</option>
   <option>pear</option>
   <option>pineapple</option>
   <option>peach</option>
   <option>strawberry</option>
   <option>raspberry</option>
   <option>cherry</option>
   <option>watermelon</option>
   <option>orange</option>
   <option>banana</option>
   <option>grape</option>
   <option>honeydew</option>
   <option>apricot</option>
</select>
```
You haven't got an Arrray there, just a string where you concatenate a new value on.

However you could still use `.includes()` [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes)

A better option would be to use an array and see if the value your attempting to add exists in it.

So change:

`var tag_array = ""` to `var tag_array = [];`

and

`tag_array = tag_array+tag+", ";` to `tag_array.push(tag)`;

Then you can do `tag_array.includes(tag)` to see if the tag exists in the array. However i would suggest doing that check before you insert the value into the array or it will always be true. [docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes)

If later you need a comma separated string of tags you can do 

`tag_array.join(', ');`