How can the first element be compared to the rest of the elements and the second element to the rest of the elements and the same repetition

I want compare between elements in the same array to get this result

      let arr = ['one','two','three','four'];
      arr.forEach((ele, i, ar)=>{
      console.log(ele, i, ar)
      for(let item = i; item< ar.length; item++ ){
        console.log (ele, ar[item])
      }
    })
    'one' => 'two',
    'one' => 'three',
    'one' => 'four',
    'two' => 'three',
    'two' => 'four',
    'three' => 'four'.

Answer

You can use two for loop, and make the second loop start from the index of the first loop + 1:

let arr = ['one','two','three','four'];


for(let i=0; i< arr.length; i++){
  for(j=i+1; j<arr.length; j++){
    console.log(arr[i],' => ', arr[j]);
  }
  }