javascript algorithms and data structures interview questions
function isPrime(n)
{
var divisor = 3,
limit = Math.sqrt(n);
//check simple cases
if (n == 2 || n == 3)
return true;
if (n % 2 == 0)
return false;
while (divisor <= limit)
{
if (n % divisor == 0)
return false;
else
divisor += 2;
}
return true;
}
> isPrime(137);
= true
> isPrime(237);
= false
Also in JavaScript:
- mongoose find by and delete
- javascript validate email address
- check if js is enabled
- javascript use regex to check for phone number
- update table remove a key from json object mysql
- react native seperator code
- jquery replicate div on drag
- change width in js
- javascript canvas beziercurveto
- password validation with regular expression in javascript
- java script member count embed
- javascript hello world
- objects are not valid as a react child
- receiving big response node js
- webpack react proxy not working
- No matching version found for swagger-jsdoc@^6.0.0.
- mobile nav react npm
- how to convert an array into an object using javascript
- javascript stringify line breaks
- jquery replace element
- gif command discordjs
- split every n character js
- github redux devtools
- angular material remove outline