Example 1 — Official Samples
Where is the number? Both samples from the Ramda docs.
console.log(R.indexOf(3, [1, 2, 3, 4])); // 2
console.log(R.indexOf(10, [1, 2, 3, 4])); // -1 How It Works
- Value first. The number to find comes before the list.
- Count from 0.
1is at 0,2at 1, so3is at2. - Not found. No item equals
10, so the answer is-1. - Always a number. Need only yes or no?
R.includesis clearer.
