This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var longestPalindrome = function(s) { | |
| if (isPalindrome(s)) { | |
| return s; | |
| } | |
| var maxP = s[0]; | |
| for (var i=0; i < s.length; i++) { | |
| var curr = s[i]; | |
| for (var j= i + 1; j < s.length; j++) { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // Using Sets | |
| function removeDupes(arr) { | |
| return [...new Set(arr)]; | |
| } | |
| // Using filter( ) | |
| function removeDupes1(arr) { | |
| return arr.filter((v,i) => arr.indexOf(v) === i) | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | console.log(["M", "A", "R", "E", "K"].includes("R")); // --> true | |
| console.log(["M", "A", "R", "E", "K"].includes("S")); // --> false | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function hasDuplicates(array) { | |
| return (new Set(array)).size !== array.length; | |
| } | |
| console.log(hasDuplicates(["M", "A", "S", "A", "U", "T", "T"])); // --> true | |
| console.log(hasDuplicates(["M", "A", "R", "E", "K"])); // --> false | |
| // https://stackoverflow.com/questions/7376598/in-javascript-how-do-i-check-if-an-array-has-duplicate-values | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function largestVal(arr) { | |
| return Math.max(...arr) | |
| } | |
| console.log(largestVal([1,9,5,4,11,3,3,4,2,])); // --> 11 | |
| // https://www.jstips.co/en/javascript/calculate-the-max-min-value-from-an-array/ | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function smallestVal(arr) { | |
| return Math.min(...arr) | |
| } | |
| console.log(smallestVal([1,9,5,4,11,3,3,4,2,])); // --> 1 | |
| // https://www.jstips.co/en/javascript/calculate-the-max-min-value-from-an-array/ | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function findIntersection(arr1, arr2) { | |
| return arr1.filter(value => arr2.includes(value)) | |
| } | |
| console.log(findIntersection(["M","A", "R", "E", "K"], ["M","A", "S", "A", "T", "T"])) // --> [ 'M', 'A' ] | |
| // https://stackoverflow.com/questions/1885557/simplest-code-for-array-intersection-in-javascript | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function removeOdds(arr){ | |
| return arr.filter(function (num) { | |
| return num % 2 === 0; | |
| }); | |
| } | |
| console.log(removeOdds([8,6,7,5,3,0,9])); // --> [ 8, 6, 0 ] | |
| // https://stackoverflow.com/questions/18305431/how-to-remove-all-odd-numbers-in-an-array-using-javascript | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function removeEvens(arr){ | |
| return arr.filter(function (num) { | |
| return num % 2 !== 0; | |
| }); | |
| } | |
| console.log(removeEvens([8,6,7,5,3,0,9])); // --> [ 7, 5, 3, 9 ] | |
| // https://stackoverflow.com/questions/18305431/how-to-remove-all-odd-numbers-in-an-array-using-javascript | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function firstDupe(arr) { | |
| return arr.findIndex((item, index) => arr.lastIndexOf(item) !== index) | |
| } | |
| console.log( firstDupe([8,6,7,5,3,0,9])); // --> -1 = !exist | |
| console.log( firstDupe(["L", "E", "T", "T", "E", "R"])); // --> 1 = E | |
| // https://stackoverflow.com/questions/39346182/javascript-how-to-find-first-duplicate-value-and-return-its-index |