javascript .firstordefault 1

javascript .firstordefault

let array = ["vera", "chuck", "dave"];
let val = array.find(x => x === "vera");

Here is what the above code is Doing:
1. We create an array of strings.
2. We call the find method on the array.
3. We pass in a function that takes a single parameter.
4. We return true if the value of the parameter is equal to “vera”.
5. The find method returns the first value in the array that matches the condition.

Similar Posts