trying to use ecmascript 6
variable concatenation.
Expecting exists
in console but getting error. Please help:
let path = 'abc';
if($('.title[data-path=${path}]').length > 0){
console.log('exists');
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class='title' data-path = 'abc'>lorem</div>
<div class='title' data-path = 'def'>ipsum</div>
<div class='title' data-path = 'abc'>lorem</div>