example lastIndexOf()

Home   »   example lastIndexOf()

const numberArray = [3,5,6,2,7,8,9,2,3,8,7];
console.log(numberArray.lastIndexOf(7)); // 10
console.log(numberArray.lastIndexOf(0)); // -1
console.log(numberArray.lastIndexOf(3)); // 8
console.log(numberArray.lastIndexOf(3,-2)); // 8
console.log(numberArray.lastIndexOf(8,-4)); // 5
console.log(numberArray.lastIndexOf(6,-6)); // 2

Leave a Reply

Your email address will not be published. Required fields are marked *