Mike Sav Mike Sav - 6 months ago 17
jQuery Question

Best way to convert result of .indexOf to a Boolean using JavaScript or jQuery

I was wondering, say I had some thing like the following:

console.log(element.find('div').eq(3).text().indexOf('whatever'));


bearing in mind that
element
is defined and the console is logging a value of 32 (or anything that isn't -1) what would be the best way of converting the result into a Boolean so my
console.log
either outputs
true
or
false


Thanks in advance.

Answer
console.log(element.find('div').eq(3).text().indexOf('whatever') > -1);