js-mentorship-razvan / javascript

Javascript study notes
GNU General Public License v3.0
22 stars 2 forks source link

Solve 'Be Concise IV - Index of an element in an array' #283

Closed odv closed 5 years ago

odv commented 5 years ago

https://www.codewars.com/kata/be-concise-iv-index-of-an-element-in-an-array/train/javascript

RazvanBugoi commented 5 years ago
function find(a,b){
return a.indexOf(b)>=0?a.indexOf(b):"Not found";
}
GabrielNunes12 commented 3 years ago

There's another way to make this possible using arrow function (ES6+) const find = (a,b) => { return a = Array.prototype.indexOf(b) >= 0 ? Array.prototype.indexOf(b) : "Not found"; }

nurstorm1 commented 1 year ago

There's another way to make this possible using arrow function (ES6+) const find = (a,b) => { return a = Array.prototype.indexOf(b) >= 0 ? Array.prototype.indexOf(b) : "Not found"; }

not works