Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. const findRep = (array) => {
  2. const compare = (x, y) => {
  3. return x == y
  4. }
  5.  
  6. const len = array.length
  7. let i, j
  8. let repeat = []
  9.  
  10. for(i = 0; i < len / 2; i++){
  11. for(j = 0; j <= i; j++){
  12. if(!compare(array[len - 2 - i - j], array[len - 1 - j])){
  13. continue
  14. }
  15. }
  16. if(i == j - 1){
  17. repeat = array.slice(len - j, len)
  18. }
  19. }
  20.  
  21. return repeat
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement