Created
January 3, 2021 14:38
-
-
Save Jagathishrex/a039e0d0a19281d12adc0ade3ee643d0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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