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: 
How about `String.indexOf()`?

```
if (tag_count != 11 && -1 === tag_array.indexOf(tag)) {
  tag_array += tag + ", ";
  tag_count = ++;
  $(".tags").append("<div style=\"margin: 5px;\" class=\"tag\"><p>" + tag + "</p><a href=\"#\">x</a></div>");
} else {
  ..
}

```
The simplest way to achieve this would be to just build the HTML of `.tags` upon the `change` event of the `select`. Then you can simply rebuild the entire list every time it changes. As an element can then only be selected once, there can be no duplicates. Try this:

```js
$("#tag_name").change(function() {
  var values = $(this).val();
  if (values.length > 10) {
    $('.tags').html('<div class="tag"><p>15 tags already selected!</p><a href="#">x</a></div>');
  } else {
    var tagsHtml = values.map(function(v) {
      return '<div class="tag"><p>' + v + '</p><a href="#">x</a></div>';
    }).join('');
    $('.tags').html(tagsHtml);
  }
});
```

```css
.tag {
  margin: 5px;
}
```

```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.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>

<div class="tags"></div>
```

Note the use of `'` as the outer string delimiter. This avoids the requirement to use the ugly escape character for inner double quotes.