# \[J-Script \] Question

**URL:** <https://forum.freecodecamp.org/t/j-script-question/136618>\
**Category:** General\
**Created:** [July 17, 2017, 3:04am UTC](https://forum.freecodecamp.org/t/j-script-question/136618 "2017-07-17T03:04:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wickz911](https://avatars.discourse-cdn.com/v4/letter/w/90db22/32.png) [@Wickz911](https://forum.freecodecamp.org/u/Wickz911)\
**Post date:** [July 17, 2017, 3:04am UTC](https://forum.freecodecamp.org/t/j-script-question/136618/1 "2017-07-17T03:04:43Z")

</div>

Write a function to take a positive integer and a prime number as an input and return true if the prime factors of the given positive integer are less than the given prime number

Example :

hasLessPrimeFactor(20,5) should return true because Prime Factors of a Number: 20 = 2 X 2 X 5

function hasLessPrimeFactor(number,primenum) {  
return false;  
}

hasLessPrimeFactor(20,5);

---

<div class="post-metadata">

**Author:** ![TheyLeftMe4Dead](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/theyleftme4dead/32/127603_2.png) [@TheyLeftMe4Dead](https://forum.freecodecamp.org/u/TheyLeftMe4Dead)\
**Post date:** [July 24, 2017, 10:47pm UTC](https://forum.freecodecamp.org/t/j-script-question/136618/2 "2017-07-24T22:47:27Z")

</div>

I’d break it down into smaller functions like so:  
//Returns an array of factors of the given number  
getFactors(num);

//Returns an array of all prime factors of the given number  
getPrimeFactors(num); //Hint: use getFactors, then trim it down

//Returns true if the prime factors of the given number are less than the given prime number  
hasLessPrimeFactor(num, primeNum)  
{  
var totalOfPrimeNums = getPrimeFactors(num).map(function(val){  
return val;  
}  
return totalOfPrimeNums \< primeNum;  
}

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 8:47pm UTC](https://forum.freecodecamp.org/t/j-script-question/136618/3 "2021-01-17T20:47:24Z")

</div>


