diff --git a/05_Day_Arrays/05_day_arrays.md b/05_Day_Arrays/05_day_arrays.md index 3a92592..6922ea2 100644 --- a/05_Day_Arrays/05_day_arrays.md +++ b/05_Day_Arrays/05_day_arrays.md @@ -390,24 +390,24 @@ Check an element if it exist in an array. const fruits = ['banana', 'orange', 'mango', 'lemon'] let index = fruits.indexOf('banana') // 0 -if(index === -1) { +if(index != -1) { console.log('This fruit does exist in the array') } else { - console.log('This fruit exists in the array') + console.log('This fruit does not exist in the array') } // This fruit exists in the array // we can use also ternary here -index === -1 -? console.log('This fruit does exist in the array') -: console.log('This fruit exists in the array') +index != -1 + ? console.log('This fruit does exist in the array') + : console.log('This fruit does not exist in the array') // let us check if a avocado exist in the array let indexOfAvocado = fruits.indexOf('avocado') // -1, if the element not found index is -1 -if(indexOfAvocado === -1) { +if(indexOfAvocado != -1) { console.log('This fruit does exist in the array') } else { - console.log('This fruit exists in the array') + console.log('This fruit does not exist in the array') } // This fruit does not exist in the array ```