Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

remove non prime numbers js

var numArray = [2, 3, 4, 5, 6, 7, 8, 9, 10]

numArray = numArray.filter((number) => {
  for (var i = 2; i <= Math.sqrt(number); i++) {
    if (number % i === 0) return false;
  }
  return true;
});

console.log(numArray);
Comment

PREVIOUS NEXT
Code Example
Javascript :: get iso date javascript 
Javascript :: set autofocus javascript 
Javascript :: check jquery version in chrome 
Javascript :: To set the dropdown default value using jquery 
Javascript :: redirect in jsp 
Javascript :: remove css inline style javascript 
Javascript :: get current page title javascript 
Javascript :: javascript get last day of month 
Javascript :: post antiforgerytoken jquery 
Javascript :: create button inside td tag javascript 
Javascript :: document ready 
Javascript :: js generate random boolean 
Javascript :: javascript factorial 
Javascript :: javascript get first 10 characters of string 
Javascript :: js how to convert all string in array into integer 
Javascript :: submit form using ajax 
Javascript :: javascript detect click outside element 
Javascript :: react native local.properties 
Javascript :: nodejs delete folder recursively 
Javascript :: how to upgrade to react 18 
Javascript :: discord.js get attachment url 
Javascript :: jquery if screen size 
Javascript :: get selected option jquery 
Javascript :: tailwind install nextjs 
Javascript :: how to find the key of an value in an object 
Javascript :: jquery select by name attribute 
Javascript :: nextjs create project with tailwind 
Javascript :: react router url params 
Javascript :: javascript through array 
Javascript :: count 1 to 5 javascript 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =