js array get index
const array1 = [5, 12, 8, 130, 44];
const search = element => element > 13;
console.log(array1.findIndex(search));
// expected output: 3
const array2 = [
{ id: 1, dev: false },
{ id: 2, dev: false },
{ id: 3, dev: true }
];
const search = obj => obj.dev === true;
console.log(array2.findIndex(search));
// expected output: 2var list = ["apple","banana","orange"]
var index_of_apple = list.indexOf("apple") // 0array.indexOf("item");var fruits = ["Banana", "Orange", "Apple", "Mango"];
return fruits.indexOf("Apple"); // Returns 2const beasts = ['ant', 'bison', 'camel', 'duck', 'bison'];
console.log(beasts.indexOf('bison'));
// expected output: 1
let ranks = [1, 5, 7, 8, 10, 7];
let index = ranks.findIndex(rank => rank === 7);
console.log(index);
Also in JavaScript:
- declaring react routes in a separate file and importing
- how to run javascript in terminal
- js refresh button
- javascript slice
- get the last option from select jquery
- javascript function exercises
- app.use(validator()) is not a function
- get index of element in array js
- how to use the onload event n vue js
- upgrading node on mac
- react native text-input-mask this.props.refInput
- javascript remove item onclick
- shadow using react native
- javascript comment
- jquery cast to string
- javascript find smallest difference between angles
- Javascript uninstall dependancy
- How to insert an item into an array at a specific index JavaScript
- Parallax.js wrapper for react
- let in javascript
- js int to string base
- remove required attribute jquery
- if condition in class angular 8
- how to give a person a role by id in discord.js