title: Finalising a coding challenge - swapping numbers
body: <p>I am trying to finalise this coding challenge: <a href="https://www.hackerrank.com/challenges/lilys-homework/problem" rel="nofollow noreferrer">https://www.hackerrank.com/challenges/lilys-homework/problem</a> , but am unsure how I should approach the last if statement. Other approaches in solving this are welcome as well.</p>
  
  <hr>
  
  <pre><code>function lilysHomework(arr) {
      console.log(arr)
      let sortedarr = arr.sort(function(a,b){return a-b})
      console.log(sortedarr)
      for(var i=0;i&lt;arr.length;i++){
        if(arr[i] == sortedarr[i]){
          continue
        } else if(arr[i] !== sortedarr[i]){
          for(var j=0; j&lt;arr.length;j++){
            if(arr[i] == sortedarr.indexOf()){
  
          }
        }
      }
    }
  </code></pre>