Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

isprime js

const array = [-3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13];

function isPrime(num) {
  for (let i = 2; num > i; i++) {
    if (num % i == 0) {
      return false;
    }
  }
  return num > 1;
}

console.log(array.filter(isPrime)); // [2, 3, 5, 7, 11, 13]
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery validation on click 
Javascript :: jquery do something if toggle open and close 
Javascript :: jquery disable all forms 
Javascript :: c# razor for loop javascript 
Javascript :: javascript get client page title 
Javascript :: jest Your test suite must contain at least one test. 
Javascript :: usecallback 
Javascript :: javascript return string 
Javascript :: flutter or react native 
Javascript :: body-parser vs express.json 
Javascript :: execute command javascript 
Javascript :: identify primary colors in img with js 
Javascript :: vscode react extensions 
Javascript :: disable input box javascript 
Javascript :: discord.js get user by username 
Javascript :: show password fa-eye javascript 
Javascript :: send sms using twilio in node 
Javascript :: node mac copy to clipboard 
Javascript :: angular lazy loading 
Javascript :: html to pdf nodejs 
Javascript :: find average of numbers 
Javascript :: angular material button align left 
Javascript :: nextjs docs 
Javascript :: for each array javascript 
Javascript :: ng-pick-datetime 
Javascript :: get request with axios 
Javascript :: change on select with javascript 
Javascript :: js entries 
Javascript :: jquery recharger la page 
Javascript :: javascript find the longest string in array 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =