FindFirstPrime

by Matthew Vasallo

JavaScript

/* 
 
 Write a method that finds the first prime number that repeats in a list of integers.
 
 
Example
[6, 3, 2, 5, 8, 3] // should return 3
[6, 3, 5, 2, 5, 8, 3] //should return 5
[4, 4, 11, 2, 5, 8, 11, 5] //should return 11
[1,2,3,4,5] // should return false
 
 
*/
 
const isPrime = num => {
    for(let i = 2, s = Math.sqrt(num); i <= s; i++)
        if(num % i === 0) return false; 
    return num > 1;
}

const findFirstPrime = () => 1;

console.log(`First Prime Is: ${findFirstPrime([6, 3, 2, 5, 8, 3])}`)