Skip to content

Instantly share code, notes, and snippets.

@Jagathishrex
Created January 3, 2021 14:38
Show Gist options
  • Save Jagathishrex/a039e0d0a19281d12adc0ade3ee643d0 to your computer and use it in GitHub Desktop.
Save Jagathishrex/a039e0d0a19281d12adc0ade3ee643d0 to your computer and use it in GitHub Desktop.
const lang = ["Java", "JavaScript"];
let hasJavaScript = function(currentElement, index, array){
console.log(`currentElement = ${currentElement}`);
console.log(`index = ${index}`);
console.log("-------------------------");
return array[index] === "JavaScript";
}
// element found in 1st index
lang.findIndex( hasJavaScript ); // 1
// output
currentElement = Java
index = 0
-------------------------
currentElement = JavaScript
index = 1
-------------------------
1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment