loading
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const fruits = ['pineapple', 'apple', 'banana','pear'];

console.log('find() example')
const foundFruit = fruits.find((element) => {
    return element.includes('apple');
});

console.log('foundFruit =', foundFruit, '\n');


console.log('for loop example');
let aFruit;
for (let i = 0; i < fruits.length; i++) {
    if (fruits[i].includes('apple')) {
        aFruit = fruits[i];
        break;
    }
}

console.log('aFruit =', aFruit);