Answers for "compare two arrays for same values js"

1

when are 2 arrays same value in javascript

// the answer when the index is not important
function arrSimilar(arr1, arr2) {

    // first lets check if the length is the same
    if (arr1.length !== arr2.length) {return false} 
    let notSimilarItemsCounter = 0
    arr1.map((item) => {
        !arr2.includes(item) ? notSimilarItemsCounter++ : true ;
    })
    if ( notSimilarItemsCounter ) {
        return false
    }else {return true}
}

//byQolam
Posted by: Guest on October-05-2021

Code answers related to "compare two arrays for same values js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language