I have this field, and I am using underscore js
I'm trying to access the _id
field if it contain .tgz
<html>
<head>
<title>_.contains() function</title>
<script type="text/javascript" src=
"https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js" >
</script>
<script type="text/javascript" src=
"https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore.js">
</script>
</head>
<body>
<script type="text/javascript">
var people = [
{"id_": "sakshi.tgz"},
{"id_": "aishwarya.zip"},
{"id_": "ajay.tgz"},
{"id_": "akansha.yml"},
{"id_": "preeti.json"}
]
console.log(_.where(people, {id_: "sakshi.tgz"}));
</script>
</body>
</html>
I only know how to do the exact match.
console.log(_.where(people, {id_: "sakshi.tgz"}));
Expected Result
As you can see, I'm trying to get 2 of them that end with .tgz
.
Any hints for me ?
Fiddle : https://codepen.io/sn4ke3ye/pen/KKzzzLj?editors=1002